javauis/mmapi_qt/baseline/src.nga/cmmasurfacewindow.cpp
changeset 26 dc7c549001d5
parent 23 98ccebc37403
child 47 f40128debb5d
child 49 35baca0e7a2e
equal deleted inserted replaced
23:98ccebc37403 26:dc7c549001d5
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 //  Include Files
    19 //  Include Files
    20 #include <logger.h>
    20 #include <logger.h>
       
    21 #include <W32STD.H>
    21 #include "cmmasurfacewindow.h"
    22 #include "cmmasurfacewindow.h"
    22 #include "cmmaplayer.h"
    23 #include "cmmaplayer.h"
    23 
    24 
    24 // Used for iDisplay member
    25 // Used for iDisplay member
    25 #include "mmmadisplay.h"
    26 #include "mmmadisplay.h"
    65 void CMMASurfaceWindow::DrawFrameL(const CFbsBitmap* /*aBitmap*/)
    66 void CMMASurfaceWindow::DrawFrameL(const CFbsBitmap* /*aBitmap*/)
    66 {
    67 {
    67     // Ignored, this window will not be used for actual drawing
    68     // Ignored, this window will not be used for actual drawing
    68 }
    69 }
    69 
    70 
    70 void CMMASurfaceWindow::SetDrawRectThread( const TRect& aRect )
    71 void CMMASurfaceWindow::SetDrawRectThread(const TRect& aRect)
    71     {
    72 {
    72     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread TL %d %d",
    73     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread TL %d %d",
    73     	aRect.iTl.iX, aRect.iTl.iY );
    74          aRect.iTl.iX, aRect.iTl.iY);
    74     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread BR %d %d",
    75     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRectThread BR %d %d",
    75     	aRect.iBr.iX, aRect.iBr.iY );
    76          aRect.iBr.iX, aRect.iBr.iY);
    76 
    77 
    77     iContentRect = aRect;
    78     iContentRect = aRect;
    78     
    79 
    79     TInt error = StaticRedrawVideo(*this);
    80     TInt error = StaticRedrawVideo(*this);
    80     if ( KErrNone != error  )
    81     if (KErrNone != error)
    81 		 {
    82     {
    82      ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error);
    83         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::SetDrawRectThread, StaticRedrawVideo error = %d", error);
    83      }
    84     }
    84     }
    85 }
    85 
    86 
    86 void CMMASurfaceWindow::SetRWindowRect(const TRect& aRect,
    87 void CMMASurfaceWindow::SetRWindowRect(const TRect& aRect,
    87                                        MMMADisplay::TThreadType aThreadType)
    88                                        MMMADisplay::TThreadType aThreadType)
    88 {
    89 {
    89 		LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect TL %d %d",
    90     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect TL %d %d",
    90                aRect.iTl.iX, aRect.iTl.iY);
    91          aRect.iTl.iX, aRect.iTl.iY);
    91     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect BR %d %d",
    92     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetRWindowRect BR %d %d",
    92                aRect.iBr.iX, aRect.iBr.iY);
    93          aRect.iBr.iX, aRect.iBr.iY);
       
    94 
       
    95     if (iRWindowRect == aRect)
       
    96     {
       
    97         return;
       
    98     }
    93 
    99 
    94     iRWindowRect = aRect;
   100     iRWindowRect = aRect;
    95 
   101 
    96     if (MMMADisplay::EMmaThread == aThreadType)
   102     if (MMMADisplay::EMmaThread == aThreadType)
    97     {
   103     {
    98         if (iDisplay)
   104         if (iDisplay)
    99         {
   105         {
   100 				/*		    iDisplay->UIGetCallback( *this,
   106             //iDisplay->UIGetCallback(*this,
   101                                     CMMASurfaceWindow::ESetDrawRect);
   107 //                                    CMMASurfaceWindow::ESetClipRect);
   102         */                            
   108             // MMAPI UI 3.x req.
   103 	     // MMAPI UI 3.x req.
   109             iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetClipRect);
   104 	     iDisplay->GetCallbackInUiThread( (TInt)CMMASurfaceWindow::ESetDrawRect );
       
   105        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect after GetCallbackInUiThread " );
       
   106 
       
   107         }
   110         }
   108     }
   111     }
   109     else if (MMMADisplay::EUiThread == aThreadType)
   112     else if (MMMADisplay::EUiThread == aThreadType)
   110     {
   113     {
   111         /*TInt error = StaticRedrawVideo(*this);
   114         TInt error = SetClipRect();
   112         if (KErrNone != error)
   115         if (KErrNone != error)
   113         {
   116         {
   114 		   LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect, StaticRedrawVideo error = %d", error);
   117             LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect, error = %d", error);
   115         }
   118         }
   116 				*/
   119     }
   117 		   LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect else GetCallbackInUiThread + " );
   120 }
   118 		   iDisplay->GetCallbackInUiThread( (TInt)CMMASurfaceWindow::ESetDrawRect );
   121 
   119        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetRWindowRect else GetCallbackInUiThread -" );
   122 TInt CMMASurfaceWindow::SetClipRect()
   120     }
   123 {
   121 }
   124     LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetClipRect");
   122 
   125 
   123 void CMMASurfaceWindow::SetDrawRect( const TRect& aRect )
   126     // CMediaClientVideoDisplay expects client to RemoveDisplayWindow
   124 		{
   127     // and AddDisplayWindow again everytime when RWindow rect changes
   125 		LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRect TL %d %d",
   128     if (iMediaClientVideoDisplay && iWindow)
   126     	aRect.iTl.iX, aRect.iTl.iY );
   129     {
   127     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDrawRect BR %d %d",
   130         iMediaClientVideoDisplay->RemoveDisplayWindow(*iWindow);
   128     	aRect.iBr.iX, aRect.iBr.iY );
   131 
   129 
       
   130 		iContentRect = aRect;
       
   131 		if ( iDisplay )
       
   132 		  {
       
   133 		 // iDisplay->UIGetCallback( *this,
       
   134 		  //                         CMMASurfaceWindow::ESetDrawRect );
       
   135 		   // MMAPI UI 3.x req.
       
   136 		   iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
       
   137        LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect, after GetCallbackInUiThread");
       
   138 		  }
       
   139 		}
       
   140 
       
   141 TInt CMMASurfaceWindow::StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow)
       
   142 {
       
   143     TRAPD(error, aSurfaceWindow.RedrawVideoL());
       
   144     return error;
       
   145 }
       
   146 
       
   147 void CMMASurfaceWindow::RedrawVideoL()
       
   148 {
       
   149     if (!iMediaClientVideoDisplay)
       
   150     {
       
   151       LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -" );
       
   152         return;
       
   153     }
       
   154 
       
   155     if (iWindow)
       
   156     {
       
   157         TRect contentRect;
   132         TRect contentRect;
   158         if (iVisible)
   133         if (iVisible)
   159         {
   134         {
   160             contentRect = iContentRect;
   135             contentRect = iContentRect;
   161             ScaleVideoL(contentRect);
       
   162         }
   136         }
   163         else
   137         else
   164         {
   138         {
   165             TRect emptyRect(0,0,0,0);
   139             TRect emptyRect(0,0,0,0);
   166             contentRect = emptyRect;
   140             contentRect = emptyRect;
   173 
   147 
   174         // setting video draw rect and adjusting it to window
   148         // setting video draw rect and adjusting it to window
   175         TRect drawRect = contentRect;
   149         TRect drawRect = contentRect;
   176         drawRect.Move(relativeParentRect.iTl);
   150         drawRect.Move(relativeParentRect.iTl);
   177 
   151 
   178         // Area where should be drawn is the intersection of drawRect and relativeParentRect.
   152         TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height());
   179         TRect areaRect = relativeParentRect;
   153         TRAPD(error, iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
   180         areaRect.Intersection(drawRect);
   154                 clipRect, // new clip rect
   181 
   155                 iVideoCropRegion,
   182         iMediaClientVideoDisplay->SetWindowClipRectL(*iWindow,
   156                 drawRect,  // video extent
   183                 areaRect,
   157                 0.0f, // ignore
       
   158                 0.0f, // ignore
       
   159                 EVideoRotationNone,
       
   160                 EAutoScaleBestFit,
       
   161                 EHorizontalAlignLeft,
       
   162                 EVerticalAlignTop,
       
   163                 (RWindow*)iWindow));
       
   164 
       
   165         LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetClipRect -");
       
   166         return error;
       
   167     }
       
   168     return KErrNone;
       
   169 }
       
   170 
       
   171 void CMMASurfaceWindow::SetDrawRect(const TRect& aRect)
       
   172 {
       
   173     LOG2(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect TL %d %d",
       
   174          aRect.iTl.iX, aRect.iTl.iY);
       
   175     LOG2(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect BR %d %d",
       
   176          aRect.iBr.iX, aRect.iBr.iY);
       
   177 
       
   178     iContentRect = aRect;
       
   179     if (iDisplay)
       
   180     {
       
   181         // iDisplay->UIGetCallback( *this,
       
   182         //                         CMMASurfaceWindow::ESetDrawRect );
       
   183         // MMAPI UI 3.x req.
       
   184         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
       
   185         LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetDrawRect, after GetCallbackInUiThread");
       
   186     }
       
   187 }
       
   188 
       
   189 TInt CMMASurfaceWindow::StaticRedrawVideo(CMMASurfaceWindow& aSurfaceWindow)
       
   190 {
       
   191     LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::RedrawVideoL +");
       
   192     TRAPD(error, aSurfaceWindow.RedrawVideoL());
       
   193     LOG1(EJavaMMAPI,EInfo,"CMMASurfaceWindow::RedrawVideoL - error = %d",error);
       
   194     return error;
       
   195 }
       
   196 
       
   197 void CMMASurfaceWindow::RedrawVideoL()
       
   198 {
       
   199     LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawVideoL +");
       
   200     if (!iMediaClientVideoDisplay)
       
   201     {
       
   202         LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: no MediaClientVideoDisplay set, aborting -");
       
   203         return;
       
   204     }
       
   205     iVisible = true;
       
   206     if (iWindow)
       
   207     {
       
   208         TRect contentRect;
       
   209         if (iVisible)
       
   210         {
       
   211             LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: if visible true iContentRect = %d X %d",iContentRect.Width(),iContentRect.Height());
       
   212             contentRect = iContentRect;
       
   213             // ScaleVideoL(contentRect);
       
   214         }
       
   215         else
       
   216         {
       
   217             LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL - if visible false");
       
   218             TRect emptyRect(0,0,0,0);
       
   219             contentRect = emptyRect;
       
   220         }
       
   221         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before intersection contentRect = %d X %d",contentRect.Width(),contentRect.Height());
       
   222 
       
   223         // align parent rect with respect to RWindow
       
   224         TRect relativeParentRect;
       
   225         relativeParentRect = iParentRect;
       
   226         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
       
   227 
       
   228         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
       
   229         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
       
   230         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iTL = %d X %d",iRWindowRect.iTl.iX,iRWindowRect.iTl.iY);
       
   231         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iRWindowRect.iBr = %d X %d\n\n",iRWindowRect.iBr.iX,iRWindowRect.iBr.iY);
       
   232 
       
   233 
       
   234 
       
   235         relativeParentRect.Move(-iRWindowRect.iTl);
       
   236         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -after moving parentRect = %d X %d",relativeParentRect.Width(),relativeParentRect.Height());
       
   237         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iTL = %d X %d",relativeParentRect.iTl.iX,relativeParentRect.iTl.iY);
       
   238         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving parentRect.iBr = %d X %d\n\n",relativeParentRect.iBr.iX,relativeParentRect.iBr.iY);
       
   239         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iTL = %d X %d",contentRect.iTl.iX,contentRect.iTl.iY);
       
   240         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - before moving draw rect.iBr = %d X %d",contentRect.iBr.iX,contentRect.iBr.iY);
       
   241 
       
   242         // setting video draw rect and adjusting it to window
       
   243         TRect drawRect = contentRect;
       
   244         drawRect.Move(relativeParentRect.iTl);
       
   245 
       
   246         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect = %d X %d",drawRect.Width(),drawRect.Height());
       
   247         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iTL = %d X %d",drawRect.iTl.iX,drawRect.iTl.iY);
       
   248         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - after moving draw rect.iBr = %d X %d",drawRect.iBr.iX,drawRect.iBr.iY);
       
   249 
       
   250 
       
   251 
       
   252         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iTL = %d X %d",iVideoCropRegion.iTl.iX,iVideoCropRegion.iTl.iY);
       
   253         LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() - iVideoCropRegion.iBr = %d X %d\n\n",iVideoCropRegion.iBr.iX,iVideoCropRegion.iBr.iY);
       
   254 
       
   255         /*TRect temp1(TPoint(127,8),TPoint(255,104));
       
   256         TRect temp2(TPoint(0,0),TPoint(128,96));
       
   257         iMediaClientVideoDisplay->SetVideoExtentL(*iWindow,
       
   258                   temp1,
       
   259                   temp2);*/
       
   260         iMediaClientVideoDisplay->SetVideoExtentL(*iWindow,
       
   261                 drawRect,
   184                 iVideoCropRegion);
   262                 iVideoCropRegion);
   185 
   263 
   186         iMediaClientVideoDisplay->SetVideoExtentL(*iWindow,
   264 
   187                 areaRect,
   265         LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawvideoL() - after setVideoExtentL");
   188                 iVideoCropRegion);
   266 
   189 
   267         //LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() -  areaRect = %d X %d",areaRect.Width(),areaRect.Height() );
   190 			LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::RedrawVideoL: RedrawWindows() areaRect is %d X %d",areaRect.Width(),areaRect.Height() );
       
   191 
   268 
   192         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   269         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   193     }
   270         LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawvideoL() - after redrawWindows");
   194 }
   271         //iMediaClientVideoDisplay->RedrawWindows(temp2);
   195 
   272         ((RWindow*)iWindow)->Invalidate();
   196 void CMMASurfaceWindow::ScaleVideoL(const TRect& aRect)
   273         LOG(EJavaMMAPI, EInfo,  "CMMASurfaceWindow::RedrawvideoL() -");
   197 {
   274     }
   198     // return without scaling incase cropregion dimensions are zero
   275 }
   199     if (!(iVideoCropRegion.Width() && iVideoCropRegion.Height()))
   276 
   200     {
   277 
   201         return;
       
   202     }
       
   203 
       
   204     TReal32 numerator = 1.0f * (aRect.Width() - iVideoCropRegion.Width());
       
   205     TReal32 denominator = 1.0f * iVideoCropRegion.Width();
       
   206     // new video width percent(relative to the original width) to
       
   207     // which video has to be scaled.
       
   208     TReal32 scaleWidthPercent = 100.0f + (100.0f * (numerator/denominator));
       
   209 
       
   210     numerator = 1.0f * (aRect.Height() - iVideoCropRegion.Height());
       
   211     denominator = 1.0f * iVideoCropRegion.Height();
       
   212     // new video height percent(relative to the original height) to
       
   213     // which video has to be scaled.
       
   214     TReal32 scaleHeightPercent = 100.0f + (100.0f * (numerator/denominator));
       
   215 
       
   216 	LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow:: scaleWidthPercent, scaleHeightPercent %d %d",
       
   217 	scaleWidthPercent, scaleHeightPercent );
       
   218 
       
   219     iMediaClientVideoDisplay->SetScaleFactorL(scaleWidthPercent,
       
   220             scaleHeightPercent,
       
   221             iVideoCropRegion);
       
   222 }
       
   223 
   278 
   224 const TRect& CMMASurfaceWindow::DrawRect()
   279 const TRect& CMMASurfaceWindow::DrawRect()
   225 {
   280 {
   226     return iContentRect;
   281     return iContentRect;
   227 }
   282 }
   231     return iParentRect.Size();
   286     return iParentRect.Size();
   232 }
   287 }
   233 
   288 
   234 void CMMASurfaceWindow::SetPosition(const TPoint& aPosition)
   289 void CMMASurfaceWindow::SetPosition(const TPoint& aPosition)
   235 {
   290 {
       
   291     LOG(EJavaMMAPI, EInfo,  "+ CMMASurfaceWindow::SetPosition");
   236     iContentRect = TRect(aPosition, iContentRect.Size());
   292     iContentRect = TRect(aPosition, iContentRect.Size());
   237     TInt error = StaticRedrawVideo(*this);
   293     TInt error = StaticRedrawVideo(*this);
   238     if (KErrNone != error)
   294     if (KErrNone != error)
   239     {
   295     {
   240    ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::SetPosition, StaticRedrawVideo error = %d", error);
   296         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::SetPosition, StaticRedrawVideo error = %d", error);
   241     }
   297     }
   242 }
   298 }
   243 
   299 
   244 TBool CMMASurfaceWindow::IsVisible() const
   300 TBool CMMASurfaceWindow::IsVisible() const
   245   {
   301 {
   246   LOG1( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::IsVisible %d ", iVisible );
   302     LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::IsVisible %d ", iVisible);
   247   return iVisible;
   303     return iVisible;
   248   }
   304 }
   249 
   305 
   250 void CMMASurfaceWindow::SetVisible(TBool aVisible, TBool aUseEventServer)
   306 void CMMASurfaceWindow::SetVisible(TBool aVisible, TBool aUseEventServer)
   251 {
   307 {
   252   LOG1( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible aVisible %d", aVisible );
   308     LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible aVisible %d", aVisible);
   253     RPointerArray< CMMAPlayer > players = iEventSource->Players();
   309     RPointerArray< CMMAPlayer > players = iEventSource->Players();
   254 
   310 
   255     if (players.Find(iPlayer) != KErrNotFound)
   311     if (players.Find(iPlayer) != KErrNotFound)
   256     {
   312     {
   257     LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible : Player found");
   313         LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible : Player found");
   258         if (aVisible != iVisible)
   314         if (aVisible != iVisible)
   259         {
   315         {
   260     	LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible: Changed visibility" );
   316             LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetVisible: Changed visibility");
   261             iVisible = aVisible;
   317             iVisible = aVisible;
   262             if (iDisplay)
   318 
       
   319             if (aUseEventServer)
   263             {
   320             {
   264       			 //MMAPI UI 3.x req.
   321                 //TInt error = StaticRedrawVideo(*this);
   265      					iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
   322                 iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
   266      					LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible,GetCallbackInUiThread");
   323                 //  if (KErrNone != error)
       
   324                 // {
       
   325                 //ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error);
       
   326                 //   }
   267             }
   327             }
   268             
   328             else // in MMA thread, so switch to UI thread
   269 
   329             {
   270 											          /*  if (aUseEventServer)
   330                 if (iDisplay)
   271 											            {
   331                 {
   272 											                TInt error = StaticRedrawVideo(*this);
   332                     //iDisplay->UIGetCallback(*this,
   273 											                if (KErrNone != error)
   333                     //                     CMMASurfaceWindow::ESetDrawRect );
   274 											                {
   334                     //MMAPI UI 3.x req.
   275 											         ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::SetVisible, StaticRedrawVideo error = %d", error);
   335                     iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
   276 											                }
   336                     LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible,GetCallbackInUiThread");
   277 											            }
   337                 }
   278 											            else // in MMA thread, so switch to UI thread
   338             }
   279 											            {
       
   280 											                if (iDisplay)
       
   281 											                {
       
   282 													      				//iDisplay->UIGetCallback(*this,
       
   283 													     				  //                     CMMASurfaceWindow::ESetDrawRect );
       
   284 													    				  //MMAPI UI 3.x req.
       
   285 													     					iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetDrawRect);
       
   286 											         					LOG(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::SetVisible,GetCallbackInUiThread");
       
   287 											                }
       
   288 											            }
       
   289 											            */
       
   290         }
   339         }
   291     }
   340     }
   292 }
   341 }
   293 
   342 
   294 void CMMASurfaceWindow::SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType /*aThreadType*/)
   343 void CMMASurfaceWindow::SetWindowRect(const TRect& aRect,MMMADisplay::TThreadType /*aThreadType*/)
   295 {
   344 {
   296     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect TL %d %d",
   345     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect TL %d %d",
   297                aRect.iTl.iX, aRect.iTl.iY);
   346          aRect.iTl.iX, aRect.iTl.iY);
   298     LOG2( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect BR %d %d",
   347     LOG2(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetWindowRect aRect BR %d %d",
   299                aRect.iBr.iX, aRect.iBr.iY);
   348          aRect.iBr.iX, aRect.iBr.iY);
   300 
   349 
   301     iParentRect = aRect;
   350     iParentRect = aRect;
   302 }
   351 }
   303 
   352 
   304 void CMMASurfaceWindow::SetVideoCropRegion(const TRect& aRect)
   353 void CMMASurfaceWindow::SetVideoCropRegion(const TRect& aRect)
   318     CleanVideoDisplay();
   367     CleanVideoDisplay();
   319 }
   368 }
   320 
   369 
   321 void CMMASurfaceWindow::SetDisplay(MMMADisplay *aDisplay)
   370 void CMMASurfaceWindow::SetDisplay(MMMADisplay *aDisplay)
   322 {
   371 {
   323     LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay +" );
   372     LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay +");
   324 
   373 
   325     if (iDisplay != aDisplay)
   374     if (iDisplay != aDisplay)
   326     {
   375     {
   327         if (iDisplay)
   376         if (iDisplay)
   328         {
   377         {
   329             // Clear the resources created within the old Display
   378             // Clear the resources created within the old Display
   330          	 iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ECleanVideoDisplay );
   379             iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ECleanVideoDisplay);
   331         }
   380         }
   332 
   381 
   333         // Set the new Display
   382         // Set the new Display
   334         iDisplay = aDisplay;
   383         iDisplay = aDisplay;
   335 
   384 
   341 
   390 
   342             display->GetWindowResources( this, MMMADisplay::EMmaThread );
   391             display->GetWindowResources( this, MMMADisplay::EMmaThread );
   343             }
   392             }
   344 
   393 
   345             */
   394             */
   346         }
   395     }
   347 
   396 
   348     LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay -" );
   397     LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::SetDisplay -");
   349     }
   398 }
   350 
   399 
   351 void CMMASurfaceWindow::ContainerSet()
   400 void CMMASurfaceWindow::ContainerSet()
   352     {
   401 {
   353     	LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ContainerSet" );
   402     LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ContainerSet");
   354     // We are in UI thread now
   403     // We are in UI thread now
   355 
   404 
   356     // Container was probably not set when
   405     // Container was probably not set when
   357     // iDisplay was set,
   406     // iDisplay was set,
   358     // we can now try get the DSA stuff again
   407     // we can now try get the DSA stuff again
   359     if (iDisplay)
   408     if (iDisplay)
   360     {
   409     {
   361         // Get a DSA stuff for the new Display
   410         // Get a DSA stuff for the new Display
   362 //        iDisplay->UIGetDSAResources( *this, MMMADisplay::EUiThread );
   411 //        iDisplay->UIGetDSAResources( *this, MMMADisplay::EUiThread );
   363         }
   412     }
   364     }
   413 }
   365 
   414 
   366 void CMMASurfaceWindow::Destroy()
   415 void CMMASurfaceWindow::Destroy()
   367     {
   416 {
   368     LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::Destroy" );
   417     LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::Destroy");
   369     // Delete itself
   418     // Delete itself
   370     delete this;
   419     delete this;
   371     }
   420 }
   372 
   421 
   373 void CMMASurfaceWindow::ProcureWindowResourcesFromQWidget(RWsSession * aWs,
   422 void CMMASurfaceWindow::ProcureWindowResourcesFromQWidget(RWsSession * aWs,
   374     CWsScreenDevice* aScreenDevice,
   423         CWsScreenDevice* aScreenDevice,
   375     RWindowBase* aWindow)
   424         RWindowBase* aWindow)
   376 	{
   425 {
   377 		iWs = aWs;
   426     iWs = aWs;
   378     iScreenDevice = aScreenDevice;
   427     iScreenDevice = aScreenDevice;
   379     iWindow = aWindow;
   428     iWindow = aWindow;
   380 		LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget" );
   429     LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget");
   381 		switch ( iVideoDisplayInitState )
   430     switch (iVideoDisplayInitState)
   382 		  {
   431     {
   383 		  	LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -7" );
   432     case EUIResourcesAndSurfaceParametersNotSet:
   384 			case EUIResourcesAndSurfaceParametersNotSet:
   433     {
   385 			     {
   434         LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -8");
   386 			     LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -8" );
   435         iVideoDisplayInitState =
   387 			     iVideoDisplayInitState =
   436             EUIResourcesSetAndSurfaceParametersNotSet;
   388 			     EUIResourcesSetAndSurfaceParametersNotSet;
   437     }
   389 			     }
   438     break;
   390 			     break;
   439     case ESurfaceParametersSetAndUIResourcesNotSet:
   391 			case ESurfaceParametersSetAndUIResourcesNotSet:
   440     {
   392 			     {
   441         LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -9");
   393 			     	LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -9" );
   442         iVideoDisplayInitState =
   394 			     iVideoDisplayInitState =
   443             EUIResourcesAndSurfaceParametersSet;
   395 			     EUIResourcesAndSurfaceParametersSet;
   444     }
   396 			     }
   445     break;
   397 			     break;
   446     // can not occur
   398 			 // can not occur
   447     case EUIResourcesSetAndSurfaceParametersNotSet:
   399 			case EUIResourcesSetAndSurfaceParametersNotSet:
   448     case EUIResourcesAndSurfaceParametersSet:
   400 		  case EUIResourcesAndSurfaceParametersSet:
   449     default:
   401 			default:
   450     {
   402            {LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -10" );
   451         LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -10");
   403       		 __ASSERT_DEBUG( EFalse, User::Invariant() );
   452         __ASSERT_DEBUG(EFalse, User::Invariant());
   404            }
   453     }
   405 			     break;
   454     break;
   406 		  }
   455     }
   407 
   456 
   408 		if( iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet )
   457     if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet)
   409 			{
   458     {
   410 				LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -11" );
   459         LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -11");
   411 			TRAPD(error, InitVideoDisplayL());
   460         TRAPD(error, InitVideoDisplayL());
   412 			LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -12" );
   461         LOG(EJavaMMAPI,EInfo, "MID::CMMASurfaceWindow::ProcureWindowResourcesFromQWidget  -12");
   413 			if ( KErrNone != error )
   462         if (KErrNone != error)
   414 				{
   463         {
   415 				ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
   464             ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
   416 				}
   465         }
   417 			}
   466     }
   418 
   467 
   419 	}
   468 }
   420 /*
   469 /*
   421 void CMMASurfaceWindow::MdcDSAResourcesCallback(
   470 void CMMASurfaceWindow::MdcDSAResourcesCallback(
   422     RWsSession &aWs,
   471     RWsSession &aWs,
   423     CWsScreenDevice &aScreenDevice,
   472     CWsScreenDevice &aScreenDevice,
   424     RWindowBase &aWindow )
   473     RWindowBase &aWindow )
   428     // We are in UI thread context now.
   477     // We are in UI thread context now.
   429     iWs = &aWs;
   478     iWs = &aWs;
   430     iScreenDevice = &aScreenDevice;
   479     iScreenDevice = &aScreenDevice;
   431     iWindow = &aWindow;
   480     iWindow = &aWindow;
   432 
   481 
   433 		switch ( iVideoDisplayInitState )
   482         switch ( iVideoDisplayInitState )
   434 		  {
   483           {
   435 			case EUIResourcesAndSurfaceParametersNotSet:
   484             case EUIResourcesAndSurfaceParametersNotSet:
   436 			     {
   485                  {
   437 			     iVideoDisplayInitState =
   486                  iVideoDisplayInitState =
   438 			     EUIResourcesSetAndSurfaceParametersNotSet;
   487                  EUIResourcesSetAndSurfaceParametersNotSet;
   439 			     }
   488                  }
   440 			     break;
   489                  break;
   441 			case ESurfaceParametersSetAndUIResourcesNotSet:
   490             case ESurfaceParametersSetAndUIResourcesNotSet:
   442 			     {
   491                  {
   443 			     iVideoDisplayInitState =
   492                  iVideoDisplayInitState =
   444 			     EUIResourcesAndSurfaceParametersSet;
   493                  EUIResourcesAndSurfaceParametersSet;
   445 			     }
   494                  }
   446 			     break;
   495                  break;
   447 			 // can not occur
   496              // can not occur
   448 			case EUIResourcesSetAndSurfaceParametersNotSet:
   497             case EUIResourcesSetAndSurfaceParametersNotSet:
   449 		  case EUIResourcesAndSurfaceParametersSet:
   498           case EUIResourcesAndSurfaceParametersSet:
   450 			default:
   499             default:
   451            {
   500            {
   452       		 __ASSERT_DEBUG( EFalse, User::Invariant() );
   501              __ASSERT_DEBUG( EFalse, User::Invariant() );
   453            }
   502            }
   454 			     break;
   503                  break;
   455 		  }
   504           }
   456 
   505 
   457 		if( iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet )
   506         if( iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet )
   458 			{
   507             {
   459 			TRAPD(error, InitVideoDisplayL());
   508             TRAPD(error, InitVideoDisplayL());
   460 			if ( KErrNone != error )
   509             if ( KErrNone != error )
   461 				{
   510                 {
   462 				LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
   511                 LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::MdcDSAResourcesCallback, error = %d", error);
   463 				}
   512                 }
   464 			}
   513             }
   465     }
   514     }
   466 */
   515 */
   467 void CMMASurfaceWindow::UICallback( TInt aCallbackId )
   516 void CMMASurfaceWindow::UICallback(TInt aCallbackId)
   468     {
   517 {
   469     // We are in UI thread context now.
   518     // We are in UI thread context now.
   470     LOG1( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::MdcUICallback CallbackId = %d", aCallbackId );
   519     LOG1(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::MdcUICallback CallbackId = %d", aCallbackId);
   471 
   520 
   472     TInt error = KErrNone;
   521     TInt error = KErrNone;
   473     switch (aCallbackId)
   522     switch (aCallbackId)
   474     {
   523     {
       
   524     case ESetClipRect:
       
   525     {
       
   526         error = SetClipRect();
       
   527         LOG1(EJavaMMAPI,EInfo,"MID::CMMASurfaceWindow::MdcUICallback,SetClipRect error = %d", error);
       
   528     }
       
   529     break;
   475     case ERemoveSurface:
   530     case ERemoveSurface:
   476     {
   531     {
   477         DoRemoveSurface();
   532         DoRemoveSurface();
   478     }
   533     }
   479     break;
   534     break;
   480     case ESetDrawRect:
   535     case ESetDrawRect:
   481     {
   536     {
   482         error = StaticRedrawVideo(*this);
   537         error = StaticRedrawVideo(*this);
   483            ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,StaticRedrawVideo error = %d", error);
   538         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,StaticRedrawVideo error = %d", error);
   484     }
   539     }
   485     break;
   540     break;
   486     case EInitVideoDisplay:
   541     case EInitVideoDisplay:
   487     {
   542     {
   488         TRAP(error, InitVideoDisplayL());
   543         TRAP(error, InitVideoDisplayL());
   489 			     ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,InitVideoDisplayL error = %d", error);
   544         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::MdcUICallback,InitVideoDisplayL error = %d", error);
   490     }
   545     }
   491     break;
   546     break;
   492     case ESetChangedSurfaceParameters:
   547     case ESetChangedSurfaceParameters:
   493     {
   548     {
   494         DoSetChangedSurfaceParameters();
   549         DoSetChangedSurfaceParameters();
   523 {
   578 {
   524     iSurfaceId = aSurfaceId;
   579     iSurfaceId = aSurfaceId;
   525     iCropRect = aCropRect;
   580     iCropRect = aCropRect;
   526     iPixelAspectRatio = aPixelAspectRatio;
   581     iPixelAspectRatio = aPixelAspectRatio;
   527 
   582 
   528     switch ( iVideoDisplayInitState )
   583     switch (iVideoDisplayInitState)
   529 		  {
   584     {
   530 			case EUIResourcesAndSurfaceParametersNotSet:
   585     case EUIResourcesAndSurfaceParametersNotSet:
   531 			     {
   586     {
   532 			     iVideoDisplayInitState =
   587         iVideoDisplayInitState =
   533 			     ESurfaceParametersSetAndUIResourcesNotSet;
   588             ESurfaceParametersSetAndUIResourcesNotSet;
   534 			     }
   589     }
   535 			     break;
   590     break;
   536 			case EUIResourcesSetAndSurfaceParametersNotSet:
   591     case EUIResourcesSetAndSurfaceParametersNotSet:
   537 			     {
   592     {
   538 			     iVideoDisplayInitState =
   593         iVideoDisplayInitState =
   539 			     EUIResourcesAndSurfaceParametersSet;
   594             EUIResourcesAndSurfaceParametersSet;
   540 			     }
   595     }
   541 			     break;
   596     break;
   542 			  // control reaches below two switch cases when
   597     // control reaches below two switch cases when
   543 			  // playback is looped using setLoopCount() in java.
   598     // playback is looped using setLoopCount() in java.
   544 		  case ESurfaceParametersSetAndUIResourcesNotSet:
   599     case ESurfaceParametersSetAndUIResourcesNotSet:
   545 		  	   {
   600     {
   546 			     }
   601     }
   547 			     break;
   602     break;
   548 			  // update surface parameters and return with out calling
   603     // update surface parameters and return with out calling
   549 			  // InitVideoDisplayL again.
   604     // InitVideoDisplayL again.
   550 			case EUIResourcesAndSurfaceParametersSet:
   605     case EUIResourcesAndSurfaceParametersSet:
   551 			     {
   606     {
   552 			    // iDisplay->UIGetCallback( *this, CMMASurfaceWindow::EResetSurfaceParameters );
   607         // iDisplay->UIGetCallback( *this, CMMASurfaceWindow::EResetSurfaceParameters );
   553 			    //MMAPI UI 3.x req.
   608         //MMAPI UI 3.x req.
   554 			    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters : switch case EUIResourcesAndSurfaceParametersSet +");
   609         LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters : switch case EUIResourcesAndSurfaceParametersSet +");
   555 			    iDisplay->GetCallbackInUiThread( (TInt)CMMASurfaceWindow::EResetSurfaceParameters );
   610         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::EResetSurfaceParameters);
   556 			    LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters : switch case EUIResourcesAndSurfaceParametersSet -");
   611         LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters : switch case EUIResourcesAndSurfaceParametersSet -");
   557 			     return;
   612         return;
   558 			     }
   613     }
   559 			     // break; not reachable
   614     // break; not reachable
   560 			default: // can not occur
   615     default: // can not occur
   561            {
   616     {
   562       		 __ASSERT_DEBUG( EFalse, User::Invariant() );
   617         __ASSERT_DEBUG(EFalse, User::Invariant());
   563            }
   618     }
   564 			     break;
   619     break;
   565 		  }
   620     }
   566 
   621 
   567     if ( iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet )
   622     if (iVideoDisplayInitState == EUIResourcesAndSurfaceParametersSet)
   568     	{
   623     {
   569     	//iDisplay->UIGetCallback( *this, CMMASurfaceWindow::EInitVideoDisplay );
   624         //iDisplay->UIGetCallback( *this, CMMASurfaceWindow::EInitVideoDisplay );
   570     	//MMAPI UI 3.x req.
   625         //MMAPI UI 3.x req.
   571     	iDisplay->GetCallbackInUiThread( (TInt)CMMASurfaceWindow::EInitVideoDisplay );
   626         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::EInitVideoDisplay);
   572 			LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters,EUIResourcesAndSurfaceParametersSet");
   627         LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetSurfaceParameters,EUIResourcesAndSurfaceParametersSet");
   573     	}
   628     }
   574 		}
   629 }
   575 
   630 
   576 void CMMASurfaceWindow::SetChangedSurfaceParameters(const TSurfaceId& aSurfaceId,
   631 void CMMASurfaceWindow::SetChangedSurfaceParameters(const TSurfaceId& aSurfaceId,
   577         const TRect& aCropRect,
   632         const TRect& aCropRect,
   578         const TVideoAspectRatio& aPixelAspectRatio)
   633         const TVideoAspectRatio& aPixelAspectRatio)
   579 {
   634 {
   582     iPixelAspectRatio = aPixelAspectRatio;
   637     iPixelAspectRatio = aPixelAspectRatio;
   583 
   638 
   584     if (iDisplay)
   639     if (iDisplay)
   585     {
   640     {
   586         //iDisplay->UIGetCallback(*this, CMMASurfaceWindow::ESetChangedSurfaceParameters);
   641         //iDisplay->UIGetCallback(*this, CMMASurfaceWindow::ESetChangedSurfaceParameters);
   587     	LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetChangedSurfaceParameters + ");
   642         LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetChangedSurfaceParameters + ");
   588     	iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetChangedSurfaceParameters);
   643         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ESetChangedSurfaceParameters);
   589     	LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetChangedSurfaceParameters - ");
   644         LOG(EJavaMMAPI,EInfo,"CMMASurfaceWindow::SetChangedSurfaceParameters - ");
   590 
   645 
   591 	}
   646     }
   592 }
   647 }
   593 
   648 
   594 void CMMASurfaceWindow::RemoveSurface()
   649 void CMMASurfaceWindow::RemoveSurface()
   595 {
   650 {
   596     if (iDisplay)
   651     if (iDisplay)
   597     {
   652     {
   598         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ERemoveSurface);                         	
   653         iDisplay->GetCallbackInUiThread((TInt)CMMASurfaceWindow::ERemoveSurface);
   599     }
   654     }
   600 }
   655 }
   601 
   656 
   602 void CMMASurfaceWindow::DoRemoveSurface()
   657 void CMMASurfaceWindow::DoRemoveSurface()
   603 {
   658 {
   613 {
   668 {
   614     __ASSERT_DEBUG((iMediaClientVideoDisplay != NULL), User::Invariant());
   669     __ASSERT_DEBUG((iMediaClientVideoDisplay != NULL), User::Invariant());
   615 
   670 
   616     if (iMediaClientVideoDisplay)
   671     if (iMediaClientVideoDisplay)
   617     {
   672     {
   618     	iMediaClientVideoDisplay->RemoveSurface();
   673         iMediaClientVideoDisplay->RemoveSurface();
   619         TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
   674         TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
   620                      iCropRect,
   675                      iCropRect,
   621                      iPixelAspectRatio,
   676                      iPixelAspectRatio,
   622                      iVideoCropRegion);
   677                      iVideoCropRegion);
   623 
   678 
   624       ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error);
   679         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::DoResetSurfaceParameters,SurfaceCreated error = %d", error);
   625 
   680 
   626         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   681         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   627     }
   682     }
   628 }
   683 }
   629 
   684 
   633     {
   688     {
   634         TInt error = iMediaClientVideoDisplay->SurfaceParametersChanged(iSurfaceId,
   689         TInt error = iMediaClientVideoDisplay->SurfaceParametersChanged(iSurfaceId,
   635                      iCropRect,
   690                      iCropRect,
   636                      iPixelAspectRatio);
   691                      iPixelAspectRatio);
   637 
   692 
   638 			ELOG1( EJavaMMAPI, "MID::CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error);
   693         ELOG1(EJavaMMAPI, "MID::CMMASurfaceWindow::DoSetChangedSurfaceParameters,SurfaceParametersChanged, error = %d", error);
   639 
   694 
   640         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   695         iMediaClientVideoDisplay->RedrawWindows(iVideoCropRegion);
   641     }
   696     }
   642 }
   697 }
   643 
   698 
   660                                        iCropRect,
   715                                        iCropRect,
   661                                        iPixelAspectRatio);
   716                                        iPixelAspectRatio);
   662 
   717 
   663     // video is not scaled untill user requests explicitly
   718     // video is not scaled untill user requests explicitly
   664     // so retain same video width & height.
   719     // so retain same video width & height.
   665     TReal32 scaleWidthPercent = 100.0f;
   720     //TReal32 scaleWidthPercent = 100.0f;
   666     TReal32 scaleHeightPercent = 100.0f;
   721     //TReal32 scaleHeightPercent = 100.0f;
   667 
   722 
   668     // video rotation feature not supported in MMAPI
   723     // video rotation feature not supported in MMAPI
   669     TVideoRotation videoRotation(EVideoRotationNone);
   724     //TVideoRotation videoRotation(EVideoRotationNone);
   670     // no automatic scaling, can be controlled only via VideoControl
   725     // no automatic scaling, can be controlled only via VideoControl
   671     TAutoScaleType autoScaleType = EAutoScaleNone;
   726     //TAutoScaleType autoScaleType = EAutoScaleNone;
   672 
   727 
   673     // always align video to the top left corner of the display area
   728     // always align video to the top left corner of the display area
   674     TInt horizontalPosition(EHorizontalAlignLeft);
   729     //TInt horizontalPosition(EHorizontalAlignLeft);
   675     TInt verticalPosition(EVerticalAlignTop);
   730     //TInt verticalPosition(EVerticalAlignTop);
   676 
   731 
   677     TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
   732     TInt error = iMediaClientVideoDisplay->SurfaceCreated(iSurfaceId,
   678                  iCropRect,
   733                  iCropRect,
   679                  iPixelAspectRatio,
   734                  iPixelAspectRatio,
   680                  iVideoCropRegion);
   735                  iVideoCropRegion);
   681 
   736 
   682 		ELOG1( EJavaMMAPI,  "MID::CMMASurfaceWindow::InitVideoDisplayL error = %d", error );
   737     ELOG1(EJavaMMAPI,  "MID::CMMASurfaceWindow::InitVideoDisplayL error = %d", error);
   683     User::LeaveIfError(error);
   738     User::LeaveIfError(error);
   684 
   739 
       
   740     TRect contentRect;
       
   741     if (iVisible)
       
   742     {
       
   743         contentRect = iContentRect;
       
   744     }
       
   745     else
       
   746     {
       
   747         TRect emptyRect(0,0,0,0);
       
   748         contentRect = emptyRect;
       
   749     }
       
   750 
       
   751     // align parent rect with respect to RWindow
       
   752     TRect relativeParentRect;
       
   753     relativeParentRect = iParentRect;
       
   754     relativeParentRect.Move(-iRWindowRect.iTl);
       
   755 
       
   756     // setting video draw rect and adjusting it to window
       
   757     TRect drawRect = contentRect;
       
   758     drawRect.Move(relativeParentRect.iTl);
       
   759 
       
   760     TRect clipRect(0,0,iRWindowRect.Width(),iRWindowRect.Height());
       
   761     //iWindow->SetExtentErr(TPoint(127,8),TSize(128,96));
   685     iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
   762     iMediaClientVideoDisplay->AddDisplayWindowL(iWindow,
   686             iContentRect,
   763             clipRect,
   687             iVideoCropRegion,
   764             iVideoCropRegion,
   688             iContentRect,
   765             drawRect,  // video extent
   689             scaleWidthPercent,
   766             0.0f, // ignore
   690             scaleHeightPercent,
   767             0.0f, // ignore
   691             videoRotation,
   768             EVideoRotationNone,
   692             autoScaleType,
   769             EAutoScaleBestFit,
   693             horizontalPosition,
   770             EHorizontalAlignLeft,
   694             verticalPosition,
   771             EVerticalAlignTop,
   695             (RWindow*)iWindow);
   772             (RWindow*)iWindow);
   696 
   773 
       
   774 
       
   775 
   697     RedrawVideoL();
   776     RedrawVideoL();
   698 }
   777 }
   699 
   778 
   700 void CMMASurfaceWindow::CleanVideoDisplay()
   779 void CMMASurfaceWindow::CleanVideoDisplay()
   701 {
   780 {
   702 		LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay +" );
   781     LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay +");
   703 
   782 
   704     SetVisible(EFalse, ETrue);
   783     SetVisible(EFalse, ETrue);
   705     if (iMediaClientVideoDisplay)
   784     if (iMediaClientVideoDisplay)
   706     {
   785     {
   707         if (iWindow)
   786         if (iWindow)
   715         iWindow = NULL;
   794         iWindow = NULL;
   716         iScreenDevice = NULL;
   795         iScreenDevice = NULL;
   717         iWs = NULL;
   796         iWs = NULL;
   718     }
   797     }
   719 
   798 
   720     LOG( EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay -" );
   799     LOG(EJavaMMAPI, EInfo,  "MID::CMMASurfaceWindow::CleanVideoDisplay -");
   721 }
   800 }
   722 
   801 
   723 
   802 
   724 CMMAPlayer* CMMASurfaceWindow::UiPlayer()
       
   725 	{
       
   726 		  return iPlayer;
       
   727 	}
       
   728 //  END OF FILE
   803 //  END OF FILE