javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/control/VideoControl.java
changeset 56 abc41079b313
parent 26 dc7c549001d5
equal deleted inserted replaced
50:023eef975703 56:abc41079b313
    22 import javax.microedition.lcdui.Canvas;
    22 import javax.microedition.lcdui.Canvas;
    23 import javax.microedition.lcdui.Display;
    23 import javax.microedition.lcdui.Display;
    24 import javax.microedition.midlet.MIDlet;
    24 import javax.microedition.midlet.MIDlet;
    25 import javax.microedition.lcdui.Item;
    25 import javax.microedition.lcdui.Item;
    26 import com.nokia.microedition.media.NativeError;
    26 import com.nokia.microedition.media.NativeError;
       
    27 import com.nokia.mj.impl.utils.Logger;
    27 
    28 
    28 //import com.symbian.midp.runtime.MIDletExecutor;
    29 //import com.symbian.midp.runtime.MIDletExecutor;
    29 import com.nokia.mj.impl.media.PlayerPermission;
    30 import com.nokia.mj.impl.media.PlayerPermission;
    30 import com.nokia.mj.impl.rt.support.ApplicationUtils;
    31 import com.nokia.mj.impl.rt.support.ApplicationUtils;
    31 
    32 
    42 // MMAPI 3.x UI req.
    43 // MMAPI 3.x UI req.
    43 import com.nokia.microedition.media.*;
    44 import com.nokia.microedition.media.*;
    44 import com.nokia.microedition.media.control.ItemDisplay;
    45 import com.nokia.microedition.media.control.ItemDisplay;
    45 
    46 
    46 import org.eclipse.swt.*;
    47 import org.eclipse.swt.*;
       
    48 import org.eclipse.swt.graphics.Rectangle;
    47 import org.eclipse.swt.widgets.*;
    49 import org.eclipse.swt.widgets.*;
    48 import javax.microedition.lcdui.*;
    50 import javax.microedition.lcdui.*;
    49 import org.eclipse.ercp.swt.mobile.MobileShell;
    51 import org.eclipse.ercp.swt.mobile.MobileShell;
    50 
    52 
    51 
    53 
   100     private static String LISTENER = ".Listener";
   102     private static String LISTENER = ".Listener";
   101 
   103 
   102     // class name used to check if eswt is included
   104     // class name used to check if eswt is included
   103     private static String ESWT_CONTROL = ".control";
   105     private static String ESWT_CONTROL = ".control";
   104 
   106 
       
   107     //Contants for display type
       
   108     private static final int DISPLAY_CANVAS = 0;
       
   109     private static final int DISPLAY_VIDEOITEM = 1;
       
   110     private static final int DISPLAY_ESWT = 2;
       
   111 
   105     protected int iStatus = NOT_INITIALIZED;
   112     protected int iStatus = NOT_INITIALIZED;
   106 
   113 
   107     // Needed for getting native handle from lcdui components
   114     // Needed for getting native handle from lcdui components
   108     //com.symbian.midp.runtime.ToolkitInvoker iToolkitInvoker;
   115     //com.symbian.midp.runtime.ToolkitInvoker iToolkitInvoker;
   109 
   116 
   110     private VideoItem iVideoItem;
   117     private VideoItem iVideoItem;
   111     private Canvas iVideoCanvas;
   118     private Canvas iVideoCanvas;
   112     private Item iItem ;
   119     private Item iItem ;
       
   120     private int iGuiType;
   113 
   121 
   114     BaseDisplay iDisplay;
   122     BaseDisplay iDisplay;
   115 //    private MIDletInstance iMIDletInstance;
   123 //    private MIDletInstance iMIDletInstance;
   116 
   124 
   117     // error code used asynchronous native calls
   125     // error code used asynchronous native calls
   122 
   130 
   123     // toolkit, stored as object as we don't have access to Toolkit class.
   131     // toolkit, stored as object as we don't have access to Toolkit class.
   124     private Object iToolkit;
   132     private Object iToolkit;
   125     // for midlet foreground statelistening
   133     // for midlet foreground statelistening
   126     //ToolkitInvoker iTlkitInvoker;
   134     //ToolkitInvoker iTlkitInvoker;
       
   135 
       
   136     //ESWT
       
   137     private org.eclipse.swt.widgets.Display eswtDisplay;
       
   138     private Control iControl;
       
   139     private ESWTProxyControl control;
   127 
   140 
   128     private Finalizer mFinalizer = new Finalizer()
   141     private Finalizer mFinalizer = new Finalizer()
   129     {
   142     {
   130         public void finalizeImpl()
   143         public void finalizeImpl()
   131         {
   144         {
   189 
   202 
   190 
   203 
   191 
   204 
   192         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplaySize()");
   205         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplaySize()");
   193 
   206 
   194 
       
   195         //canvasdisplay.setDisplaySize( aWidth, aHeight);
   207         //canvasdisplay.setDisplaySize( aWidth, aHeight);
   196         iDisplay.setDisplaySize(aWidth, aHeight);
   208         //iDisplay.setDisplaySize(aWidth, aHeight);
   197 
   209 
   198         /*
   210         if (iGuiType == DISPLAY_ESWT)
       
   211         {
       
   212             //iDisplay.setDisplaySize(aWidth, aHeight);
       
   213         }
   199         int ret = setDisplayProperty(aWidth, aHeight, SET_DISPLAY_SIZE);
   214         int ret = setDisplayProperty(aWidth, aHeight, SET_DISPLAY_SIZE);
   200         if (ret < 0)
   215         if (ret < 0)
   201         {
   216         {
   202             throw new MediaException("setDisplaySize() failed, SymbianOS error: "
   217             throw new MediaException("setDisplaySize() failed, SymbianOS error: "
   203                                                     + ret);
   218                                      + ret);
   204         }
   219         }
   205         if (iStatus == USE_GUI_PRIMITIVE &&
   220         if (iStatus == USE_GUI_PRIMITIVE &&
   206                 iVideoItem != null)  // with dynamic display mode item can be null
   221                 iVideoItem != null)  // with dynamic display mode item can be null
   207         {
   222         {
   208             iVideoItem.privateInvalidate();
   223             //iVideoItem.privateInvalidate();
   209         }
   224         }
   210 
   225 
   211         */
   226 
   212     }
   227     }
   213 
   228 
   214     /**
   229     /**
   215      * from Interface VideoControl
   230      * from Interface VideoControl
   216      *
   231      *
   217      */
   232      */
   218     public void setDisplayFullScreen(boolean aFullScreenMode) throws MediaException
   233     public void setDisplayFullScreen(boolean aFullScreenMode) throws MediaException
       
   234     {
       
   235         checkState();
       
   236 
       
   237         if (iStatus == NOT_INITIALIZED)
       
   238         {
       
   239             throw new IllegalStateException(
       
   240                 "VideoControl.initDisplayMode() not called yet");
       
   241         }
       
   242 
       
   243         int ret;
       
   244         if (aFullScreenMode)
       
   245         {
       
   246             if (iGuiType == DISPLAY_ESWT)
       
   247             {
       
   248                 iDisplay.setDisplayFullScreen(aFullScreenMode);
       
   249             }
       
   250             //Rectangle fullscreenRect = iDisplay.getFullScreenBounds();
       
   251             Rectangle fullscreenRect = iDisplay.getBounds();
       
   252             System.out.println("MMAPI: setDisplayFullscreen size width = " + fullscreenRect.width + " height = " + fullscreenRect.height);
       
   253             ret = setDisplayProperty(fullscreenRect.width, fullscreenRect.height, SET_DISPLAY_FULLSCREEN_TRUE);
       
   254         }
       
   255         else
       
   256         {
       
   257             ret = setDisplayProperty(SET_DISPLAY_FULLSCREEN_FALSE);
       
   258         }
       
   259 
       
   260         if (ret < 0)
       
   261         {
       
   262             throw new MediaException();
       
   263         }
       
   264 
       
   265 
       
   266         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplayFullScreen()");
       
   267         //canvasdisplay.setDisplayFullScreen( aFullScreenMode);
       
   268 //       iDisplay.setDisplayFullScreen(aFullScreenMode);
       
   269 
       
   270 
       
   271     }
       
   272 
       
   273     /**
       
   274      * from Interface VideoControl
       
   275      *
       
   276      */
       
   277     public void setDisplayLocation(int aX, int aY)
       
   278     {
       
   279         checkState();
       
   280         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"VideoControl.java :: setDisplayLocation x, y = " + aX + ","+ aY);
       
   281         if (iStatus == USE_GUI_PRIMITIVE)
       
   282         {
       
   283             // In USE_GUI_PRIMITIVE mode, this call will be ignored.
       
   284             return;
       
   285         }
       
   286         if (iStatus != USE_DIRECT_VIDEO)
       
   287         {
       
   288             // This method only works when the USE_DIRECT_VIDEO mode is set.
       
   289             throw new IllegalStateException();
       
   290         }
       
   291 
       
   292         // cannot fail -> ignore return value
       
   293         setDisplayProperty(aX, aY, SET_DISPLAY_LOCATION);
       
   294 
       
   295 
       
   296         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplayLocation()");
       
   297         //canvasdisplay.setDisplayLocation( aX , aY);
       
   298         //iDisplay.setDisplayLocation(aX , aY);
       
   299 
       
   300     }
       
   301 
       
   302     /**
       
   303      * from Interface VideoControl
       
   304      *
       
   305      */
       
   306     public void setVisible(boolean aVisible)
   219     {
   307     {
   220         // checkState();
   308         // checkState();
   221         if (iStatus == NOT_INITIALIZED)
   309         if (iStatus == NOT_INITIALIZED)
   222         {
   310         {
   223             throw new IllegalStateException(
   311             throw new IllegalStateException(
   224                 "VideoControl.initDisplayMode() not called yet");
   312                 "VideoControl.initDisplayMode() not called yet");
   225         }
   313         }
   226         /*
   314         if (aVisible)
   227         int ret;
       
   228         if (aFullScreenMode)
       
   229         {
       
   230             ret = setDisplayProperty(SET_DISPLAY_FULLSCREEN_TRUE);
       
   231         }
       
   232         else
       
   233         {
       
   234             ret = setDisplayProperty(SET_DISPLAY_FULLSCREEN_FALSE);
       
   235         }
       
   236 
       
   237         if (ret < 0)
       
   238         {
       
   239             throw new MediaException();
       
   240         }
       
   241 
       
   242         */
       
   243         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplayFullScreen()");
       
   244         //canvasdisplay.setDisplayFullScreen( aFullScreenMode);
       
   245         iDisplay.setDisplayFullScreen(aFullScreenMode);
       
   246 
       
   247 
       
   248     }
       
   249 
       
   250     /**
       
   251      * from Interface VideoControl
       
   252      *
       
   253      */
       
   254     public void setDisplayLocation(int aX, int aY)
       
   255     {
       
   256         // checkState();
       
   257         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"VideoControl.java :: setDisplayLocation x, y = " + aX + ","+ aY);
       
   258         if (iStatus == USE_GUI_PRIMITIVE)
       
   259         {
       
   260             // In USE_GUI_PRIMITIVE mode, this call will be ignored.
       
   261             return;
       
   262         }
       
   263         if (iStatus != USE_DIRECT_VIDEO)
       
   264         {
       
   265             // This method only works when the USE_DIRECT_VIDEO mode is set.
       
   266             throw new IllegalStateException();
       
   267         }
       
   268         /*
       
   269             // cannot fail -> ignore return value
       
   270             setDisplayProperty(aX, aY, SET_DISPLAY_LOCATION);
       
   271         */
       
   272 
       
   273         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setDisplayLocation()");
       
   274         //canvasdisplay.setDisplayLocation( aX , aY);
       
   275         iDisplay.setDisplayLocation(aX , aY);
       
   276 
       
   277     }
       
   278 
       
   279     /**
       
   280      * from Interface VideoControl
       
   281      *
       
   282      */
       
   283     public void setVisible(boolean aVisible)
       
   284     {
       
   285         // checkState();
       
   286         if (iStatus == NOT_INITIALIZED)
       
   287         {
       
   288             throw new IllegalStateException(
       
   289                 "VideoControl.initDisplayMode() not called yet");
       
   290         }
       
   291         /*if (aVisible)
       
   292         {
   315         {
   293             // Update the foreground or background state of the midlet before
   316             // Update the foreground or background state of the midlet before
   294             // setting the visibility of the control
   317             // setting the visibility of the control
   295             updateForeground();
   318             //updateForeground();
   296             // cannot fail -> ignore return value
   319             // cannot fail -> ignore return value
   297             setDisplayProperty(SET_DISPLAY_VISIBLE_TRUE);
   320             setDisplayProperty(SET_DISPLAY_VISIBLE_TRUE);
   298         }
   321         }
   299         else
   322         else
   300         {
   323         {
   301             // cannot fail -> ignore return value
   324             // cannot fail -> ignore return value
   302             setDisplayProperty(SET_DISPLAY_VISIBLE_FALSE);
   325             setDisplayProperty(SET_DISPLAY_VISIBLE_FALSE);
   303         }
   326         }
   304         */
   327 
   305         Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   328         Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   306                    " before iDisplay.setVisible()");
   329                    " before iDisplay.setVisible()");
   307         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setVisible()");
   330         Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"inside setVisible()");
   308         // canvasdisplay.setVisible( aVisible );
   331 
   309         iDisplay.setVisible(aVisible);
   332         //iDisplay.setVisible(aVisible);
   310         Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   333         Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   311                    "after iDisplay.setVisible()");
   334                    "after iDisplay.setVisible()");
   312 
   335 
   313 
   336 
   314 
   337 
   318      * from Interface VideoControl
   341      * from Interface VideoControl
   319      *
   342      *
   320      */
   343      */
   321     public int getDisplayWidth()
   344     public int getDisplayWidth()
   322     {
   345     {
   323         /*
   346         checkState();
   324            checkState();
   347         if (iStatus == NOT_INITIALIZED)
   325            if (iStatus == NOT_INITIALIZED)
   348         {
   326            {
   349             throw new IllegalStateException(
   327                throw new IllegalStateException(
   350                 "VideoControl.initDisplayMode() not called yet");
   328                "VideoControl.initDisplayMode() not called yet");
   351         }
   329            }
   352         int width = getControlProperty(PROPERTY_DISPLAY_WIDTH);
   330            int width = getControlProperty(PROPERTY_DISPLAY_WIDTH);
   353         return width;
   331            return width;
       
   332            */
       
   333         //return  canvasdisplay.getDisplayWidth( );
       
   334         return iDisplay.getDisplayWidth();
       
   335     }
   354     }
   336 
   355 
   337     /**
   356     /**
   338      * from Interface VideoControl
   357      * from Interface VideoControl
   339      *
   358      *
   340      */
   359      */
   341     public int getDisplayHeight()
   360     public int getDisplayHeight()
   342     {
   361     {
   343         /* checkState();
   362         checkState();
   344          if (iStatus == NOT_INITIALIZED)
   363         if (iStatus == NOT_INITIALIZED)
   345          {
   364         {
   346              throw new IllegalStateException(
   365             throw new IllegalStateException(
   347              "VideoControl.initDisplayMode() not called yet");
   366                 "VideoControl.initDisplayMode() not called yet");
   348          }
   367         }
   349          int height = getControlProperty(PROPERTY_DISPLAY_HEIGHT);
   368         int height = getControlProperty(PROPERTY_DISPLAY_HEIGHT);
   350          return height;
   369         return height;
   351 
   370 
   352          */
   371 
   353         return  iDisplay.getDisplayHeight();
   372         //return  iDisplay.getDisplayHeight();
   354     }
   373     }
   355 
   374 
   356     /**
   375     /**
   357      * from Interface VideoControl
   376      * from Interface VideoControl
   358      *
   377      *
   359      */
   378      */
   360     public int getDisplayX()
   379     public int getDisplayX()
   361     {
   380     {
   362         /* checkState();
   381         checkState();
   363          if (iStatus == NOT_INITIALIZED)
   382         if (iStatus == NOT_INITIALIZED)
   364          {
   383         {
   365              return UNDEFINED_RETURN_VALUE;
   384             return UNDEFINED_RETURN_VALUE;
   366          }
   385         }
   367          int x = getControlProperty(PROPERTY_DISPLAY_X);
   386         int x = getControlProperty(PROPERTY_DISPLAY_X);
   368          return x;
   387         return x;
   369          */
   388 
   370         return  iDisplay.getDisplayX();
   389         //return  iDisplay.getDisplayX();
   371     }
   390     }
   372 
   391 
   373     /**
   392     /**
   374      * from Interface VideoControl
   393      * from Interface VideoControl
   375      *
   394      *
   376      */
   395      */
   377     public int getDisplayY()
   396     public int getDisplayY()
   378     {
   397     {
   379         /*
   398 
   380         checkState();
   399         checkState();
   381         if (iStatus == NOT_INITIALIZED)
   400         if (iStatus == NOT_INITIALIZED)
   382         {
   401         {
   383             return UNDEFINED_RETURN_VALUE;
   402             return UNDEFINED_RETURN_VALUE;
   384         }
   403         }
   385         int y = getControlProperty(PROPERTY_DISPLAY_Y);
   404         int y = getControlProperty(PROPERTY_DISPLAY_Y);
   386         return y;
   405         return y;
   387 
   406 
   388         */
   407 
   389         return  iDisplay.getDisplayY();
   408         // return  iDisplay.getDisplayY();
   390     }
   409     }
   391 
   410 
   392     /**
   411     /**
   393      * from Interface VideoControl
   412      * from Interface VideoControl
   394      *
   413      *
   395      */
   414      */
   396     public int getSourceWidth()
   415     public int getSourceWidth()
   397     {
   416     {
   398         /* checkState();
   417         checkState();
   399          int width = getControlProperty(PROPERTY_SOURCE_WIDTH);
   418         int width = getControlProperty(PROPERTY_SOURCE_WIDTH);
   400          if (width <= 0)
   419         if (width <= 0)
   401          {
   420         {
   402              width = 1;
   421             width = 1;
   403          }
   422         }
   404          return width;
   423         return width;
   405 
   424 
   406          */
   425 
   407         return  iDisplay.getSourceWidth();
   426         //return  0;//iDisplay.getSourceWidth();
   408     }
   427     }
   409 
   428 
   410     /**
   429     /**
   411      * from Interface VideoControl
   430      * from Interface VideoControl
   412      *
   431      *
   413      */
   432      */
   414     public int getSourceHeight()
   433     public int getSourceHeight()
   415     {
   434     {
   416         /*checkState();
   435         checkState();
   417         int height = getControlProperty(PROPERTY_SOURCE_HEIGHT);
   436         int height = getControlProperty(PROPERTY_SOURCE_HEIGHT);
   418         if (height <= 0)
   437         if (height <= 0)
   419         {
   438         {
   420             height = 1;
   439             height = 1;
   421         }
   440         }
   422         return height;
   441         return height;
   423         */
   442 
   424         return  iDisplay.getSourceHeight();
   443         //return  0;//iDisplay.getSourceHeight();
   425 
   444 
   426     }
   445     }
   427 
   446 
   428     /**
   447     /**
   429      * from Interface VideoControl
   448      * from Interface VideoControl
   490             // called again after it has previously been called successfully.
   509             // called again after it has previously been called successfully.
   491             throw new IllegalStateException(
   510             throw new IllegalStateException(
   492                 "initDisplayMode() already called successfully");
   511                 "initDisplayMode() already called successfully");
   493         }
   512         }
   494 
   513 
       
   514         if (aArg != null && aArg.equals(Control.class.getName()))
       
   515         {
       
   516             eswtDisplay = org.eclipse.swt.widgets.Display.getDefault();
       
   517         }
       
   518         else
       
   519         {
       
   520             eswtDisplay = com.nokia.mj.impl.nokialcdui.LCDUIInvoker.getEswtDisplay();
       
   521         }
   495         if (aMode == USE_GUI_PRIMITIVE)
   522         if (aMode == USE_GUI_PRIMITIVE)
   496         {
   523         {
   497             Object guiObject = null;
   524             Object guiObject = null;
   498             if (aArg == null)
   525             if (aArg == null)
   499             {
   526             {
   506                     guiObject = initLCDUI();
   533                     guiObject = initLCDUI();
   507                 }
   534                 }
   508                 else // try load dynamic display mode
   535                 else // try load dynamic display mode
   509                 {
   536                 {
   510                     guiObject = initDynamicDisplayMode(aArg);
   537                     guiObject = initDynamicDisplayMode(aArg);
       
   538 
       
   539                     iControl = (Control)guiObject;
       
   540 
       
   541                     iDisplay = new MMAeSWTDisplay(iEventSource, iControl);
       
   542                     int handle = initNativeDisplay(iControl, iDisplay, iGuiType);
       
   543                     Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"MMAPI: VideoControl.java: initDisplayMode(): nativeDisplayHandle = " + handle);
       
   544                     iDisplay.setNativeHandle(handle);
       
   545                     ESWTProxyControl proxyControl = (ESWTProxyControl)iControl;
       
   546                     proxyControl.seteSWTDisplay(iDisplay);
       
   547                     proxyControl.setNativeDisplayHandle(handle);
       
   548                     //display.setWindowResources();
       
   549 
       
   550                     iStatus = USE_GUI_PRIMITIVE;
       
   551                     return iControl;
   511                 }
   552                 }
   512             }
   553             }
   513 
   554 
   514             //iItem = (Item)aArg;
   555             //iItem = (Item)aArg;
   515 
   556 
   519             iDisplay = new ItemDisplay(iEventSource , iVideoItem);
   560             iDisplay = new ItemDisplay(iEventSource , iVideoItem);
   520 
   561 
   521             Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   562             Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,
   522                        "VideoControl : creation of ItemDisplay");
   563                        "VideoControl : creation of ItemDisplay");
   523 
   564 
   524             int handle = initNativeDisplay(iVideoItem, iDisplay, true);
   565             int handle = initNativeDisplay(iVideoItem, iDisplay, DISPLAY_VIDEOITEM);
   525             // here actual listener is added to iDisplay
   566             // here actual listener is added to iDisplay
   526             iDisplay.setNativeHandle(handle);
   567             iDisplay.setNativeHandle(handle);
   527             iVideoItem.setNativeHandle(handle);
   568             iVideoItem.setNativeHandle(handle);
   528             // Window resource initialization is done to the native video player
   569             // Window resource initialization is done to the native video player
   529             //iDisplay.setWindowResources();
   570             //iDisplay.setWindowResources();
   546             {
   587             {
   547                 throw new java.lang.IllegalArgumentException(
   588                 throw new java.lang.IllegalArgumentException(
   548                     "For USE_DIRECT_VIDEO mode argument should not be null");
   589                     "For USE_DIRECT_VIDEO mode argument should not be null");
   549             }
   590             }
   550             iVideoCanvas = (Canvas)aArg;
   591             iVideoCanvas = (Canvas)aArg;
       
   592             iGuiType = DISPLAY_CANVAS;
   551             // MMAPI UI 3.x req.
   593             // MMAPI UI 3.x req.
   552 
   594 
   553             iDisplay = new MMACanvasDisplay(iEventSource , iVideoCanvas);
   595             iDisplay = new MMACanvasDisplay(iEventSource , iVideoCanvas);
   554 
   596 
   555             Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"VideoControl.java: after eswt control got from canvas has added observer");
   597             Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"VideoControl.java: after eswt control got from canvas has added observer");
   556 
   598 
   557             int handle = initNativeDisplay(iVideoCanvas, iDisplay, false);
   599             int handle = initNativeDisplay(iVideoCanvas, iDisplay, DISPLAY_CANVAS);
   558             // here actual listener is added to iDisplay
   600             // here actual listener is added to iDisplay
   559             iDisplay.setNativeHandle(handle);
   601             iDisplay.setNativeHandle(handle);
   560             // Window resource initialization is done to the native video player
   602             // Window resource initialization is done to the native video player
   561             iDisplay.setWindowResources(null);
   603             iDisplay.setWindowResources(null);
   562             iStatus = USE_DIRECT_VIDEO;
   604             iStatus = USE_DIRECT_VIDEO;
   591 
   633 
   592     /**
   634     /**
   593      * Initializes native display.
   635      * Initializes native display.
   594      *
   636      *
   595      */
   637      */
   596     private int initNativeDisplay(Object aGuiObject, Object mmadisplay, boolean aGuiType)
   638     private int initNativeDisplay(Object aGuiObject, Object mmadisplay, int aGuiType)
   597     {
   639     {
   598         int handle = _initDisplayMode(iControlHandle,
   640         int handle = _initDisplayMode(iControlHandle,
   599                                       iEventSource,
   641                                       iEventSource,
   600                                       mmadisplay,
   642                                       mmadisplay,
   601                                       aGuiObject,
   643                                       aGuiObject,
   611      */
   653      */
   612     private int getControlProperty(int aPropertyType)
   654     private int getControlProperty(int aPropertyType)
   613     {
   655     {
   614         return _getControlProperty(iControlHandle,
   656         return _getControlProperty(iControlHandle,
   615                                    iEventSource,
   657                                    iEventSource,
   616                                    aPropertyType);
   658                                    aPropertyType,
       
   659                                    iGuiType);
   617     }
   660     }
   618 
   661 
   619     /**
   662     /**
   620      * Sets two properties to native side.
   663      * Sets two properties to native side.
   621      *
   664      *
   627     {
   670     {
   628         return _setDisplayProperty(iControlHandle,
   671         return _setDisplayProperty(iControlHandle,
   629                                    iEventSource,
   672                                    iEventSource,
   630                                    aParamA,
   673                                    aParamA,
   631                                    aParamB,
   674                                    aParamB,
   632                                    aPropertyType);
   675                                    aPropertyType,
       
   676                                    iGuiType);
   633     }
   677     }
   634 
   678 
   635     /**
   679     /**
   636      * Sets one property to native side.
   680      * Sets one property to native side.
   637      *
   681      *
   641     {
   685     {
   642         return _setDisplayProperty(iControlHandle,
   686         return _setDisplayProperty(iControlHandle,
   643                                    iEventSource,
   687                                    iEventSource,
   644                                    0,
   688                                    0,
   645                                    0,
   689                                    0,
   646                                    aPropertyType);
   690                                    aPropertyType,
       
   691                                    iGuiType);
   647     }
   692     }
   648 
   693 
   649     /**
   694     /**
   650      * Called from native side when snapshot is ready
   695      * Called from native side when snapshot is ready
   651      *
   696      *
   667      * @param aMode parameter for display mode
   712      * @param aMode parameter for display mode
   668      * @return GUI object
   713      * @return GUI object
   669      */
   714      */
   670     private Object initDynamicDisplayMode(Object aMode)
   715     private Object initDynamicDisplayMode(Object aMode)
   671     {
   716     {
   672         MMAGUIFactory guiFactory = null;
   717         //MMAGUIFactory guiFactory = null;
   673         try
   718         try
   674         {
   719         {
   675             String className = ((String)aMode).toLowerCase() +
   720             // String className = ((String)aMode).toLowerCase();
   676                                GUI_FACTORY_CLASS_NAME;
   721             //GUI_FACTORY_CLASS_NAME;*/
   677             Class guiClass = Class.forName(className);
   722             Class guiClass = Class.forName((String)aMode);
   678             guiFactory = (MMAGUIFactory)guiClass.newInstance();
   723             //guiFactory = (MMAGUIFactory)guiClass.newInstance();
       
   724             Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"MMAPI: VideoControl.java: After loading class");
       
   725             eswtDisplay.syncExec(new Runnable()
       
   726             {
       
   727                 public void run()
       
   728                 {
       
   729                     Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"MMAPI: VideoControl.java: Before creating ESWTProxyControl.");
       
   730                     control = new ESWTProxyControl();
       
   731                     Logger.LOG(Logger.EJavaMMAPI,Logger.EInfo,"MMAPI: VideoControl.java: ESWTProxyControl created.");
       
   732                 }
       
   733             });
   679         }
   734         }
   680         catch (ClassNotFoundException cnfe)
   735         catch (ClassNotFoundException cnfe)
   681         {
   736         {
   682             // if the class could not be found
   737             // if the class could not be found
   683             throw new IllegalArgumentException(
   738             throw new IllegalArgumentException(
   684                 "Mode not supported or invalid, " +
   739                 "Mode not supported or invalid, " +
   685                 "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE");
   740                 "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE");
   686         }
   741         }
   687         catch (IllegalAccessException iae)
   742         /*       catch (IllegalAccessException iae)
   688         {
   743                {
   689             // if the class or initializer is not accessible
   744                    // if the class or initializer is not accessible
   690             throw new IllegalArgumentException("Mode: " + aMode +
   745                    throw new IllegalArgumentException("Mode: " + aMode +
   691                                                " caused " + iae);
   746                                                       " caused " + iae);
   692         }
   747                }
   693         catch (InstantiationException ie)
   748                catch (InstantiationException ie)
   694         {
   749                {
   695             // if an application tries to instantiate an abstract class or an
   750                    // if an application tries to instantiate an abstract class or an
   696             // interface, or if the instantiation fails for some other reason
   751                    // interface, or if the instantiation fails for some other reason
   697             throw new IllegalArgumentException("Mode: " + aMode +
   752                    throw new IllegalArgumentException("Mode: " + aMode +
   698                                                " caused " + ie);
   753                                                       " caused " + ie);
   699         }
   754                }*/
   700         catch (ClassCastException cce)
   755         catch (ClassCastException cce)
   701         {
   756         {
   702             // Thrown to indicate that the code has attempted to cast an
   757             // Thrown to indicate that the code has attempted to cast an
   703             // object to a subclass of which it is not an instance.
   758             // object to a subclass of which it is not an instance.
   704             throw new IllegalArgumentException("Mode: " + aMode +
   759             throw new IllegalArgumentException("Mode: " + aMode +
   705                                                " caused " + cce);
   760                                                " caused " + cce);
   706         }
   761         }
   707 
   762 
   708         Object guiObject = guiFactory.initDisplayMode();
   763         //Object guiObject = guiFactory.initDisplayMode();
   709         // initNativeDisplay return handle MMMADirectContainer, 0 parameter
   764         // initNativeDisplay return handle MMMADirectContainer, 0 parameter
   710         // indicates that dynamic display will be used
   765         // indicates that dynamic display will be used
   711         // MMAPI UI 3.x req.
   766         // MMAPI UI 3.x req.
   712         //  guiFactory.setContentHandle(initNativeDisplay(guiObject, 0));
   767         //  guiFactory.setContentHandle(initNativeDisplay(guiObject, 0));
   713         return guiObject;
   768         iGuiType = DISPLAY_ESWT;
       
   769         return control;
   714     }
   770     }
   715 
   771 
   716     /**
   772     /**
   717      * Initializes LCDUI display mode.
   773      * Initializes LCDUI display mode.
   718      * @return LCDUI Item
   774      * @return LCDUI Item
   869     private native int _construct(int aControlHandle,
   925     private native int _construct(int aControlHandle,
   870                                   int aEventSourceHandle);
   926                                   int aEventSourceHandle);
   871 
   927 
   872     private native int _getControlProperty(int aControlHandle,
   928     private native int _getControlProperty(int aControlHandle,
   873                                            int aEventSourceHandle,
   929                                            int aEventSourceHandle,
   874                                            int aPropertyType);
   930                                            int aPropertyType,
       
   931                                            int aGuiType);
   875 
   932 
   876     private native int _setDisplayProperty(int aControlHandle,
   933     private native int _setDisplayProperty(int aControlHandle,
   877                                            int aEventSourceHandle,
   934                                            int aEventSourceHandle,
   878                                            int aParamA,
   935                                            int aParamA,
   879                                            int aParamB,
   936                                            int aParamB,
   880                                            int aPropertyType);
   937                                            int aPropertyType,
       
   938                                            int aGuiType);
   881 
   939 
   882     private native int _getSnapshot(int aControlHandle,
   940     private native int _getSnapshot(int aControlHandle,
   883                                     int aEventSourceHandle,
   941                                     int aEventSourceHandle,
   884                                     String aProperties);
   942                                     String aProperties);
   885 
   943 
   886     private native int _initDisplayMode(int aControlHandle,
   944     private native int _initDisplayMode(int aControlHandle,
   887                                         int aEventSourceHandle,
   945                                         int aEventSourceHandle,
   888                                         Object aJavaDisplay,
   946                                         Object aJavaDisplay,
   889                                         Object aJavaDisplayObject,
   947                                         Object aJavaDisplayObject,
   890                                         boolean aGuiTYpe);
   948                                         int aGuiTYpe);
   891     private native int _setForeground(int aControlHandle,
   949     private native int _setForeground(int aControlHandle,
   892                                       int aEventSourceHandle,
   950                                       int aEventSourceHandle,
   893                                       int aIsForeground);
   951                                       int aIsForeground);
   894 
   952 
   895     private native boolean _isESWT();
   953     private native boolean _isESWT();