changeset 7590:df28c1bdf2e1

RT-37914: [Linux] JavaFX Media does not run on Ubuntu 14.04
author stayer
date Mon, 28 Jul 2014 19:25:24 +0400
parents af217a8598ef
children 86ffa7810b12
files build.gradle modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c modules/media/src/main/native/gstreamer/projects/linux/avplugin/Makefile
diffstat 3 files changed, 45 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Mon Jul 28 10:34:17 2014 +0200
+++ b/build.gradle	Mon Jul 28 19:25:24 2014 +0400
@@ -2150,15 +2150,26 @@
                 def buildAVPlugin = task( "buildAVPlugin", dependsOn: [buildPlugins]) {
                     enabled = IS_COMPILE_MEDIA
 
-                    if (!project.ext.properties.containsKey("LIBAV"))
-                        project.ext.LIBAV = "";
-
                     doLast {
-                        // Building fxavcodec plugin (libav plugin)
-                        exec {
-                            commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin")
-                            args("CC=${mediaProperties.compiler}", "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 
-                                     "BASE_NAME=avplugin", "LIBAV_DIR=${project.ext.LIBAV}")
+                        if (project.ext.properties.containsKey("libav")) {
+                            project.ext.libav.versions.each { version ->
+                                def libavDir = "${project.ext.libav.basedir}-${version}"
+                                File dir = file(libavDir)
+                                if (dir.exists()) {
+                                    exec {
+                                        commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin")
+                                        args("CC=${mediaProperties.compiler}", "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 
+                                             "BASE_NAME=avplugin", "VERSION=${version}", "LIBAV_DIR=${libavDir}")
+                                    }
+                                }
+                            }
+                        } else {
+                            // Building fxavcodec plugin (libav plugin)
+                            exec {
+                                commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin")
+                                args("CC=${mediaProperties.compiler}", "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 
+                                     "BASE_NAME=avplugin")
+                            }
                         }
                     }
                 }
@@ -2877,13 +2888,16 @@
                     [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
                         from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library(name)}") }
                     
-                    if (t.name == "linux") from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library("avplugin")}")
-                    else from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library("glib-lite")}")                        
+                    if (t.name == "linux") {
+                        from("modules/media/build/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" }
+                    } else from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library("glib-lite")}")                        
                 } else {
                     [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
                         from ("$LIBRARY_STUB/${library(name)}") }
 
-                    if (t.name == "linux") from ("$LIBRARY_STUB/${library("avplugin")}")
+                    if (t.name == "linux") {
+                        from(LIBRARY_STUB) { include "libavplugin*.so" }
+                    }
                     else from ("$LIBRARY_STUB/${library("glib-lite")}")
                 }
                 
--- a/modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Mon Jul 28 10:34:17 2014 +0200
+++ b/modules/media/src/main/native/gstreamer/gstreamer-lite/gstreamer/gst/gstregistry.c	Mon Jul 28 19:25:24 2014 +0400
@@ -1253,10 +1253,9 @@
 #ifdef LINUX
       if (g_str_has_suffix(filename_partial, "libavplugin")) // Check libav version and load correspondent module.
       {
-          int vi;
-          for (vi = 0, avcHandle = NULL; 
-               vi < (sizeof(AVCODEC_EXPLICIT_VERSIONS)/sizeof(AVCODEC_EXPLICIT_VERSIONS[0])) && !avcHandle; 
-               vi++)
+          int vi = (sizeof(AVCODEC_EXPLICIT_VERSIONS)/sizeof(AVCODEC_EXPLICIT_VERSIONS[0]));
+          
+          while(!avcHandle && --vi >= 0)
           {
               int version = AVCODEC_EXPLICIT_VERSIONS[vi];
               gchar* libname = g_strdup_printf("libavcodec.so.%d", version);
@@ -1265,7 +1264,18 @@
           }
               
           if (avcHandle)
+          {
+              dlclose(avcHandle);
+              avcHandle = NULL;
+
+              // Try simple name first. OpenJDK build may contain the latest bits.
               filename = g_strdup_printf("%s%s", filename_partial, GST_EXTRA_MODULE_SUFFIX);
+              if (g_stat (filename, &file_status) < 0) // Not available, create a versioned filename
+              { 
+                  g_free(filename);
+                  filename = g_strdup_printf("%s-%d%s", filename_partial, AVCODEC_EXPLICIT_VERSIONS[vi], GST_EXTRA_MODULE_SUFFIX);
+              }
+          }
           else
           {
               g_free(filename_partial);
@@ -1358,13 +1368,6 @@
           file_status.st_size, file_status.st_mtime);
     }
 
-#ifdef LINUX
-    if (avcHandle)
-    {
-        dlclose(avcHandle);
-        avcHandle = NULL;
-    }
-#endif // LINUX
     g_free (filename);
   }
 
--- a/modules/media/src/main/native/gstreamer/projects/linux/avplugin/Makefile	Mon Jul 28 10:34:17 2014 +0200
+++ b/modules/media/src/main/native/gstreamer/projects/linux/avplugin/Makefile	Mon Jul 28 19:25:24 2014 +0400
@@ -6,11 +6,16 @@
 TARGET_DIRS = $(BUILD_DIR)
 
 SRCBASE_DIR = ../../../plugins
-OBJBASE_DIR = $(BUILD_DIR)/obj/plugins/avplugin
 
 DIRLIST = av
 
+ifneq ($(strip $(VERSION)),)
+TARGET = $(BUILD_DIR)/lib$(BASE_NAME)-$(VERSION).so
+OBJBASE_DIR = $(BUILD_DIR)/obj/plugins/avplugin-$(VERSION)
+else
 TARGET = $(BUILD_DIR)/lib$(BASE_NAME).so
+OBJBASE_DIR = $(BUILD_DIR)/obj/plugins/avplugin
+endif
 
 CFLAGS = -fPIC                   \
          -Werror=implicit-function-declaration \