javauis/mmapi_qt/baseline/src/cmmavideocontrol.cpp
changeset 49 35baca0e7a2e
parent 26 dc7c549001d5
child 56 abc41079b313
equal deleted inserted replaced
35:85266cc22c7f 49:35baca0e7a2e
   127 void CMMAVideoControl::StaticInitL(CMMAVideoControl* aControl,
   127 void CMMAVideoControl::StaticInitL(CMMAVideoControl* aControl,
   128                                    jobject javaDisplayRef,
   128                                    jobject javaDisplayRef,
   129                                    MMAFunctionServer* aEventSource,
   129                                    MMAFunctionServer* aEventSource,
   130                                    TInt* aDisplayHandle,
   130                                    TInt* aDisplayHandle,
   131                                    CMMAEvent* aDeleteRefEvent,
   131                                    CMMAEvent* aDeleteRefEvent,
   132                                    TBool aGuiType)
   132                                    TInt aGuiType)
   133 {
   133 {
   134 
   134 
   135     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL +");
   135     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL +");
   136 
   136 
   137     if (aGuiType == true)
   137     if (aGuiType == CMMAVideoControl::EDISPLAY_VIDEOITEM)
   138     {
   138     {
   139         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL - aGuiType is customitem ");
   139         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL - aGuiType is customitem ");
   140         aControl->iDeleteRefEvent = aDeleteRefEvent;
   140         aControl->iDeleteRefEvent = aDeleteRefEvent;
   141 
   141 
   142         CMMAItemDisplay* itemDisplay =
   142         CMMAItemDisplay* itemDisplay =
   143             CMMAItemDisplay::NewLC(aEventSource,javaDisplayRef);
   143             CMMAItemDisplay::NewLC(aEventSource,javaDisplayRef);
   144         aControl->iDisplay = itemDisplay;
   144         aControl->iDisplay = itemDisplay;
   145         CleanupStack::Pop(itemDisplay);
   145         CleanupStack::Pop(itemDisplay);
   146         *aDisplayHandle = reinterpret_cast<TInt>(itemDisplay);
   146         *aDisplayHandle = reinterpret_cast<TInt>(itemDisplay);
   147     }
   147     }
   148     else
   148     else if (aGuiType == CMMAVideoControl::EDISPLAY_CANVAS)
   149     {
   149     {
   150         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL - aGuiType is canvas ");
   150         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitL - aGuiType is canvas ");
   151         aControl->iDeleteRefEvent = aDeleteRefEvent;
   151         aControl->iDeleteRefEvent = aDeleteRefEvent;
   152 
   152 
   153         CMMACanvasDisplay* canvasDisplay =
   153         CMMACanvasDisplay* canvasDisplay =
   213     TRAP_IGNORE(iGuiPlayer->SetDisplayL(iDisplay));
   213     TRAP_IGNORE(iGuiPlayer->SetDisplayL(iDisplay));
   214 }
   214 }
   215 
   215 
   216 void CMMAVideoControl::StaticInitDynamicModeL(
   216 void CMMAVideoControl::StaticInitDynamicModeL(
   217     CMMAVideoControl* aVideoControl,
   217     CMMAVideoControl* aVideoControl,
       
   218     JNIEnv* aJni,
   218     TInt* aContentHandle,
   219     TInt* aContentHandle,
   219     MMAFunctionServer* aEventSource,
   220     MMAFunctionServer* aEventSource,
   220     jobject aGUIObject,
   221     jobject aGUIObject,
   221     CMMAEvent* aDeleteRefEvent)
   222     CMMAEvent* aDeleteRefEvent)
   222 {
   223 {
   223     LOG(EJavaMMAPI,EInfo,"MMA::CMMAVideoControl::StaticInitDynamicModeL+");
   224     LOG(EJavaMMAPI,EInfo,"MMA::CMMAVideoControl::StaticInitDynamicModeL+");
   224     aVideoControl->iDeleteRefEvent = aDeleteRefEvent;
   225     aVideoControl->iDeleteRefEvent = aDeleteRefEvent;
   225 
   226 
   226     CMMADCDisplay* dcDisplay = CMMADCDisplay::NewLC(aVideoControl->iGuiPlayer,
   227     CMMADCDisplay* dcDisplay = CMMADCDisplay::NewLC(aVideoControl->iGuiPlayer,
   227                                aEventSource,
   228                                aEventSource,
       
   229                                aJni,
   228                                aGUIObject);
   230                                aGUIObject);
   229 
   231 
   230     MMMADirectContent* content = dcDisplay;
   232     //MMMADirectContent* content = dcDisplay;
   231     *aContentHandle = reinterpret_cast< TInt >(content);
   233     *aContentHandle = reinterpret_cast< TInt >(dcDisplay);
   232     aVideoControl->iDisplay = dcDisplay;
   234     aVideoControl->iDisplay = dcDisplay;
   233     aVideoControl->iGuiPlayer->SetDisplayL(aVideoControl->iDisplay);
   235     aVideoControl->iGuiPlayer->SetDisplayL(aVideoControl->iDisplay);
   234     CleanupStack::Pop(dcDisplay);
   236     CleanupStack::Pop(dcDisplay);
   235     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitDynamicModeL-");
   237     LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticInitDynamicModeL-");
   236 }
   238 }
   237 
   239 
   238 void CMMAVideoControl::StaticGetPropertyL(CMMAVideoControl* /*aControl*/,
   240 void CMMAVideoControl::StaticGetPropertyL(CMMAVideoControl* aControl,
   239         TInt /*aPropertyType*/,
   241         TInt aPropertyType,
   240         TInt* /*aReturnValue*/)
   242         TInt* aReturnValue)
   241 {
   243 {
   242     // LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL property %d",
   244     LOG1(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL property %d",
   243     //           aPropertyType);
   245          aPropertyType);
   244 
   246 
   245 // MMAPI UI 3.x req.
   247 // MMAPI UI 3.x req.
   246 // remove the below return and uncomment the below code once  display is implemented in java
   248 // remove the below return and uncomment the below code once  display is implemented in java
   247     return;
   249 //    return;
   248 
   250 
   249     /*
   251 
   250      MMMADisplay* display = aControl->iDisplay;
   252     MMMADisplay* display = aControl->iDisplay;
   251 
   253 
   252      if (aPropertyType != com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_WIDTH &&
   254     if (aPropertyType != com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_WIDTH &&
   253              aPropertyType != com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_HEIGHT &&
   255             aPropertyType != com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_HEIGHT &&
   254              !display)
   256             !display)
   255      {
   257     {
   256          LOG( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL not initialized yet");
   258         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL not initialized yet");
   257          // init is not done yet, returning 0
   259         // init is not done yet, returning 0
   258          *aReturnValue = 0;
   260         *aReturnValue = 0;
   259          return;
   261         return;
   260      }
   262     }
   261 
   263 
   262      switch (aPropertyType)
   264     switch (aPropertyType)
   263      {
   265     {
   264      case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_WIDTH:
   266     case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_WIDTH:
   265      {
   267     {
   266          *aReturnValue = display->DisplaySize().iWidth;
   268         *aReturnValue = display->DisplaySize().iWidth;
   267          break;
   269         break;
   268      }
   270     }
   269      case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_HEIGHT:
   271     case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_HEIGHT:
   270      {
   272     {
   271          *aReturnValue = display->DisplaySize().iHeight;
   273         *aReturnValue = display->DisplaySize().iHeight;
   272          break;
   274         LOG1(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL aReturnValue %d",
   273      }
   275              *aReturnValue);
   274      case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_X:
   276         break;
   275      {
   277     }
   276          *aReturnValue = display->DisplayLocation().iX;
   278     case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_X:
   277          break;
   279     {
   278      }
   280         *aReturnValue = display->DisplayLocation().iX;
   279      case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_Y:
   281         break;
   280      {
   282     }
   281          *aReturnValue = display->DisplayLocation().iY;
   283     case com_nokia_microedition_media_control_VideoControl_PROPERTY_DISPLAY_Y:
   282          break;
   284     {
   283      }
   285         *aReturnValue = display->DisplayLocation().iY;
   284      case com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_WIDTH:
   286         break;
   285      {
   287     }
   286          LOG( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL get source width");
   288     case com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_WIDTH:
   287          *aReturnValue = aControl->iGuiPlayer->SourceSize().iWidth;
   289     {
   288          break;
   290         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL get source width");
   289      }
   291         *aReturnValue = aControl->iGuiPlayer->SourceSize().iWidth;
   290      case com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_HEIGHT:
   292         break;
   291      {
   293     }
   292          LOG( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL get source height");
   294     case com_nokia_microedition_media_control_VideoControl_PROPERTY_SOURCE_HEIGHT:
   293          *aReturnValue = aControl->iGuiPlayer->SourceSize().iHeight;
   295     {
   294          break;
   296         LOG(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticGetPropertyL get source height");
   295      }
   297         *aReturnValue = aControl->iGuiPlayer->SourceSize().iHeight;
   296      default:
   298         break;
   297      {
   299     }
   298          *aReturnValue = KErrNotFound;
   300     default:
   299          User::Leave(KErrNotFound);
   301     {
   300          break;
   302         *aReturnValue = KErrNotFound;
   301      }
   303         User::Leave(KErrNotFound);
   302      }
   304         break;
   303      */
   305     }
   304 }
   306     }
   305 
   307 
   306 
   308 }
   307 void CMMAVideoControl::StaticSetPropertyL(CMMAVideoControl* /*aControl*/,
   309 
   308         TInt /*aPropertyType*/,
   310 
   309         TInt /*aPropertyA*/,
   311 void CMMAVideoControl::StaticSetPropertyL(CMMAVideoControl* aControl,
   310         TInt /*aPropertyB*/)
   312         TInt aPropertyType,
       
   313         TInt aPropertyA,
       
   314         TInt aPropertyB)
   311 {
   315 {
   312     //LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL property type %d",
   316     //LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL property type %d",
   313     //          aPropertyType);
   317     //          aPropertyType);
   314     //LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL a property %d",
   318     //LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL a property %d",
   315     //         aPropertyA);
   319     //         aPropertyA);
   316     // LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL b property %d",
   320     // LOG1( EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL b property %d",
   317     //          aPropertyB);
   321     //          aPropertyB);
   318 // MMAPI UI 3.x req.
   322 // MMAPI UI 3.x req.
   319 // remove the below return and uncomment the below code; once  display is implemented in java
   323 // remove the below return and uncomment the below code; once  display is implemented in java
   320     return;
   324     // return;
   321 
   325 
   322     /*
   326 
   323         MMMADisplay* display = aControl->iDisplay;
   327     MMMADisplay* display = aControl->iDisplay;
   324 
   328 
   325         __ASSERT_DEBUG(display != NULL,
   329     __ASSERT_DEBUG(display != NULL,
   326                        User::Panic(_L("display not initialized"), KErrNotReady));
   330                    User::Panic(_L("display not initialized"), KErrNotReady));
   327 
   331 
   328         switch (aPropertyType)
   332     switch (aPropertyType)
       
   333     {
       
   334     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_SIZE:
       
   335     {
       
   336         TSize displaySize(aPropertyA, aPropertyB);
       
   337         LOG2(EJavaMMAPI, EInfo, "CMMAVideoControl::statepropertyl %d , %d",displaySize.iHeight,displaySize.iWidth);
       
   338         display->SetDisplaySizeL(displaySize);
       
   339         LOG(EJavaMMAPI, EInfo, "CMMAVideoControl::SetDisplayProperty:: setDisplaySizeL Completed");
       
   340         // inform java side
       
   341         if (!display->IsFullScreen())
   329         {
   342         {
   330         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_SIZE:
   343             aControl->iGuiPlayer->NotifyWithStringEvent(
   331         {
   344                 CMMAPlayerEvent::ESizeChanged, KControlName);
   332             TSize displaySize(aPropertyA, aPropertyB);
       
   333             display->SetDisplaySizeL(displaySize);
       
   334 
       
   335             // inform java side
       
   336             if (!display->IsFullScreen())
       
   337             {
       
   338                 aControl->iGuiPlayer->NotifyWithStringEvent(
       
   339                     CMMAPlayerEvent::ESizeChanged, KControlName);
       
   340             }
       
   341             break;
       
   342         }
   345         }
   343         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_LOCATION:
   346         break;
   344         {
   347     }
   345             TPoint displayLocation(aPropertyA, aPropertyB);
   348     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_LOCATION:
   346             display->SetDisplayLocationL(displayLocation);
   349     {
   347             break;
   350         TPoint displayLocation(aPropertyA, aPropertyB);
   348         }
   351         display->SetDisplayLocationL(displayLocation);
   349         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_VISIBLE_TRUE:
   352         break;
   350         {
   353     }
   351             display->SetVisible(ETrue);
   354     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_VISIBLE_TRUE:
   352             break;
   355     {
   353         }
   356         display->SetVisible(ETrue);
   354         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_VISIBLE_FALSE:
   357         break;
   355         {
   358     }
   356             display->SetVisible(EFalse);
   359     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_VISIBLE_FALSE:
   357             break;
   360     {
   358         }
   361         display->SetVisible(EFalse);
   359         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_FULLSCREEN_TRUE:
   362         break;
   360         {
   363     }
   361             // store old user rect to determine if SIZE_CHANGED event
   364     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_FULLSCREEN_TRUE:
   362             // has to be delivered when full screen mode is turned off.
   365     {
   363             aControl->iOldDisplaySize = display->DisplaySize();
   366         // store old user rect to determine if SIZE_CHANGED event
   364 
   367         // has to be delivered when full screen mode is turned off.
   365             display->SetFullScreenL(ETrue);
   368         aControl->iOldDisplaySize = display->DisplaySize();
   366             break;
   369         LOG1(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL a property %d",
   367         }
   370              aPropertyA);
   368         case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_FULLSCREEN_FALSE:
   371         LOG1(EJavaMMAPI, EInfo, "MMA::CMMAVideoControl::StaticSetPropertyL b property %d",
   369         {
   372              aPropertyB);
   370             display->SetFullScreenL(EFalse);
   373         //TSize fullscreenSize(aPropertyA, aPropertyB);
   371 
   374         //display->SetFullscreenSize(fullscreenSize);
   372             // Send SIZE_CHANGED event when fullscreen is turned off if
   375         //display->SetDisplaySizeL(fullscreenSize);
   373             // size of the video display has changed. Possible position
   376         //display->SetFullScreenL(ETrue);
   374             // change is however disregarded
   377         display->SourceSizeChanged(aPropertyA, aPropertyB,0,0,TRect(0,0,0,0));
   375             if (aControl->iOldDisplaySize != display->DisplaySize())
   378         break;
   376             {
   379     }
   377                 aControl->iGuiPlayer->NotifyWithStringEvent(
   380     case com_nokia_microedition_media_control_VideoControl_SET_DISPLAY_FULLSCREEN_FALSE:
   378                     CMMAPlayerEvent::ESizeChanged, KControlName);
   381     {
   379             }
   382         TSize fullscreenSize = aControl->iOldDisplaySize;
   380 
   383         display->SetFullscreenSize(fullscreenSize);
   381             break;
   384         display->SetFullScreenL(EFalse);
   382         }
   385 
   383         default:
   386         // Send SIZE_CHANGED event when fullscreen is turned off if
   384         {
   387         // size of the video display has changed. Possible position
   385             User::Leave(KErrNotFound);
   388         // change is however disregarded
   386             break;
   389         /* if (aControl->iOldDisplaySize != display->DisplaySize())
   387         }
   390          {
   388         }
   391              aControl->iGuiPlayer->NotifyWithStringEvent(
   389         */
   392                  CMMAPlayerEvent::ESizeChanged, KControlName);
       
   393          }*/
       
   394 
       
   395         break;
       
   396     }
       
   397     default:
       
   398     {
       
   399         User::Leave(KErrNotFound);
       
   400         break;
       
   401     }
       
   402     }
       
   403 
   390 }
   404 }
   391 
   405 
   392 
   406 
   393 void CMMAVideoControl::TakeSnapShotL(CMMAVideoControl* aControl,
   407 void CMMAVideoControl::TakeSnapShotL(CMMAVideoControl* aControl,
   394                                      const TDesC* aProperties)
   408                                      const TDesC* aProperties)
   489     {
   503     {
   490         iDisplay->SetForeground(iIsForeground, aUseEventServer);
   504         iDisplay->SetForeground(iIsForeground, aUseEventServer);
   491     }
   505     }
   492 }
   506 }
   493 
   507 
   494 
   508 /*
       
   509 MMMAGuiPlayer* CMMAVideoControl::GuiPlayer()
       
   510 {
       
   511     return iGuiPlayer;
       
   512 }
       
   513 */
   495 /**
   514 /**
   496  * Handles a change to resources which are shared accross the environment.
   515  * Handles a change to resources which are shared accross the environment.
   497  */
   516  */
   498 /*
   517 /*
   499 void CMMAVideoControl::HandleResourceChangeL(TInt aType)
   518 void CMMAVideoControl::HandleResourceChangeL(TInt aType)