Commits

Anonymous committed 37977ea

avmedia101: added fallback to JMF backend for UNIX systems

  • Participants
  • Parent commits c247972

Comments (0)

Files changed (7)

avmedia/source/inc/mediamisc.hxx

 #define AVMEDIA_RESID( nId ) ResId( nId, * ::avmedia::GetResMgr() )
 
 #ifdef WNT 
-#define AVMEDIA_MANAGER_SERVICE_NAME            "com.sun.star.comp.avmedia.Manager_DirectX"
-#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED    sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME                    "com.sun.star.comp.avmedia.Manager_DirectX"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED            sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1          ""
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1  sal_False
+
 #else
 #ifdef QUARTZ
-#define AVMEDIA_MANAGER_SERVICE_NAME            "com.sun.star.comp.avmedia.Manager_QuickTime"
-#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED    sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME                    "com.sun.star.comp.avmedia.Manager_QuickTime"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED            sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1           ""
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1  sal_False
+
 #else
-#define AVMEDIA_MANAGER_SERVICE_NAME            "com.sun.star.comp.avmedia.Manager_GStreamer"
-#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED    sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME                    "com.sun.star.comp.avmedia.Manager_GStreamer"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED            sal_False
+
+#define AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1          "com.sun.star.comp.avmedia.Manager_Java"
+#define AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1  sal_True
+
 #endif
 #endif
  

avmedia/source/java/PlayerWindow.java

 
                 maFrame = new WindowAdapter( AnyConverter.toInt( aArgs[ 0 ] ) );
                 maFrame.setPosSize( aBoundRect.X, aBoundRect.Y, aBoundRect.Width, aBoundRect.Height, (short) 0 );
-
-                if( aArgs.length > 2 )
-                    mbShowControls = AnyConverter.toBoolean( aArgs[ 2 ] );
+                mbShowControls = false;
 
                 java.awt.Panel aPanel = new java.awt.Panel( new java.awt.BorderLayout() );
 

avmedia/source/java/avmedia.jar

Binary file modified.

avmedia/source/viewer/mediawindow.cxx

         {
             try
             {
+                sal_Bool bIsJavaBasedMediaWindow;
     	        uno::Reference< media::XPlayer > xPlayer( priv::MediaWindowImpl::createPlayer(
-        	                                                aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ) ) );
+        	                                                aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS ),
+                                                            bIsJavaBasedMediaWindow ) );
 
             	if( xPlayer.is() )
                 {
 
 uno::Reference< media::XPlayer > MediaWindow::createPlayer( const ::rtl::OUString& rURL )
 {
-    return priv::MediaWindowImpl::createPlayer( rURL );
+    sal_Bool bJavaBased = sal_False;
+    return priv::MediaWindowImpl::createPlayer( rURL, bJavaBased );
 }
 
 // -------------------------------------------------------------------------

avmedia/source/viewer/mediawindow_impl.cxx

     if( getPlayer().is() )
     {
         uno::Reference< media::XPlayerWindow > xPlayerWindow;
-    	const Point                            aPoint;
-		const Size					           aSize( maChildWindow.GetSizePixel() );
-        const sal_IntPtr                       nWndHandle = (sal_IntPtr) maChildWindow.
-                                                    GetParentWindowHandle( AVMEDIA_MANAGER_SERVICE_IS_JAVABASED );
+    	
+        const Point         aPoint;
+		const Size          aSize( maChildWindow.GetSizePixel() );
+        const sal_IntPtr    nWndHandle = (sal_IntPtr) maChildWindow.GetParentWindowHandle( isMediaWindowJavaBased() );
 
         try
         {

avmedia/source/viewer/mediawindowbase_impl.cxx

 // - MediaWindowBaseImpl -
 // -----------------------
 
+struct ServiceManager
+{
+	const char* pServiceName;
+    sal_Bool    bIsJavaBased;
+};
+
+// ---------------------------------------------------------------------
+
+
 MediaWindowBaseImpl::MediaWindowBaseImpl( MediaWindow* pMediaWindow ) :
-    mpMediaWindow( pMediaWindow )
+    mpMediaWindow( pMediaWindow ),
+    mbIsMediaWindowJavaBased( sal_False )
 {
 }
 
 
 // -------------------------------------------------------------------------
 
-uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL )
+uno::Reference< media::XPlayer > MediaWindowBaseImpl::createPlayer( const ::rtl::OUString& rURL, sal_Bool& rbJavaBased )
 {
     uno::Reference< lang::XMultiServiceFactory >    xFactory( ::comphelper::getProcessServiceFactory() );
     uno::Reference< media::XPlayer >                xPlayer;
 
+    rbJavaBased = sal_False;
+
     if( xFactory.is() )
     {
-        try
+        static const ServiceManager aServiceManagers[] =
         {
-        
-            uno::Reference< ::com::sun::star::media::XManager > xManager(
-                xFactory->createInstance( ::rtl::OUString::createFromAscii( AVMEDIA_MANAGER_SERVICE_NAME ) ),
-                uno::UNO_QUERY );
-    
-            if( xManager.is() )
+            { "AVMEDIA_MANAGER_SERVICE_NAME", AVMEDIA_MANAGER_SERVICE_IS_JAVABASED },
+            { "AVMEDIA_MANAGER_SERVICE_NAME_FALLBACK1", AVMEDIA_MANAGER_SERVICE_IS_JAVABASED_FALLBACK1 }
+        };
+
+        uno::Reference< media::XManager > xManager;
+
+        for( sal_uInt32 i = 0; ( i < ( sizeof( aServiceManagers ) / sizeof( ServiceManager ) ) ) && !xManager.is(); ++i )
+        {
+            const String aServiceName( aServiceManagers[ i ].pServiceName, RTL_TEXTENCODING_ASCII_US );
+
+            if( aServiceName.Len() )
             {
-                xPlayer = uno::Reference< ::com::sun::star::media::XPlayer >(
-                    xManager->createPlayer( rURL ), uno::UNO_QUERY );
+                try
+                {
+                    xManager = uno::Reference< media::XManager >( xFactory->createInstance( aServiceName ),
+                                                                  uno::UNO_QUERY );
+
+                    if( xManager.is() )
+                    {
+                        xPlayer = uno::Reference< media::XPlayer >( xManager->createPlayer( rURL ),
+                                                                    uno::UNO_QUERY );
+                    }
+                }
+                catch( ... )
+                {
+                }
             }
-        }
-        catch( ... )
-        {
+
+            if( !xPlayer.is() )
+            {
+                xManager.clear();
+            }
+            else
+            {
+                rbJavaBased = aServiceManagers[ i ].bIsJavaBased;
+            }
         }
     }
     
         if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
             maFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
             
-        mxPlayer = createPlayer( maFileURL );
+        mxPlayer = createPlayer( maFileURL, mbIsMediaWindowJavaBased );
         onURLChanged();
     }
 }

avmedia/source/viewer/mediawindowbase_impl.hxx

             virtual void 	cleanUp();
 			virtual void	onURLChanged();
 			
-    		static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL );
+    		static ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > createPlayer( const ::rtl::OUString& rURL,
+                                                                                                      sal_Bool& rbJavaBased );
 		
 		public:
 
             void	stopPlayingInternal( bool );
 
             MediaWindow* getMediaWindow() const;
+            inline sal_Bool isMediaWindowJavaBased() const { return( mbIsMediaWindowJavaBased ); }
 
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > getPlayer() const;
 
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayer > 		mxPlayer;
             ::com::sun::star::uno::Reference< ::com::sun::star::media::XPlayerWindow >	mxPlayerWindow;
             MediaWindow*                                                                mpMediaWindow;
+            sal_Bool                                                                    mbIsMediaWindowJavaBased;
         };
     }
 }