Bug 842327 - Move libomxplugin* at the root of the apk. r=doublec,r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 04 Mar 2013 19:34:03 +0100
changeset 123706 58bb59eb40fefa86e9fed3d9c1ed0f78c19d8b0a
parent 123705 a1b333710699d82f12ca8e5f8554bd7178f7840d
child 123707 b55a438b74e27b314b70a6e7c80fa1b80f43afdf
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-esr52@1c070ab0f9db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdoublec, khuey
bugs842327
milestone22.0a1
Bug 842327 - Move libomxplugin* at the root of the apk. r=doublec,r=khuey
content/media/plugins/MediaPluginHost.cpp
toolkit/mozapps/installer/packager.mk
--- a/content/media/plugins/MediaPluginHost.cpp
+++ b/content/media/plugins/MediaPluginHost.cpp
@@ -10,16 +10,17 @@
 #include "nsHTMLMediaElement.h"
 #include "MediaPluginHost.h"
 #include "nsXPCOMStrings.h"
 #include "nsISeekableStream.h"
 #include "pratom.h"
 #include "MediaPluginReader.h"
 #include "nsIGfxInfo.h"
 #include "gfxCrashReporterUtils.h"
+#include "prmem.h"
 
 #include "MPAPI.h"
 
 #if defined(ANDROID) || defined(MOZ_WIDGET_GONK)
 #include "android/log.h"
 #define ALOG(args...)  __android_log_print(ANDROID_LOG_INFO, "MediaPluginHost" , ## args)
 #else
 #define ALOG(args...) /* do nothing */
@@ -165,63 +166,77 @@ static const char* GetOmxLibraryName()
 
   if (version == 15 &&
       (device.Find("LT28", false) == 0 ||
        device.Find("LT26", false) == 0 ||
        device.Find("LT22", false) == 0 ||
        device.Find("IS12", false) == 0 ||
        device.Find("MT27", false) == 0)) {
     // Sony Ericsson devices running ICS
-    return "lib/libomxpluginsony.so";
+    return "libomxpluginsony.so";
   }
   else if (version == 13 || version == 12 || version == 11) {
-    return "lib/libomxpluginhc.so";
+    return "libomxpluginhc.so";
   }
   else if (version == 10 && release_version >= NS_LITERAL_STRING("2.3.6")) {
     // Gingerbread versions from 2.3.6 and above have a different DataSource
     // layout to those on 2.3.5 and below.
-    return "lib/libomxplugingb.so";
+    return "libomxplugingb.so";
   }
   else if (version == 10 && release_version >= NS_LITERAL_STRING("2.3.4") &&
            device.Find("HTC") == 0) {
     // HTC devices running Gingerbread 2.3.4+ (HTC Desire HD, HTC Evo Design, etc) seem to
     // use a newer version of Gingerbread libstagefright than other 2.3.4 devices.
-    return "lib/libomxplugingb.so";
+    return "libomxplugingb.so";
   }
   else if (version == 9 || (version == 10 && release_version <= NS_LITERAL_STRING("2.3.5"))) {
     // Gingerbread versions from 2.3.5 and below have a different DataSource
     // than 2.3.6 and above.
-    return "lib/libomxplugingb235.so";
+    return "libomxplugingb235.so";
   }
   else if (version == 8) {
     // Froyo
-    return "lib/libomxpluginfroyo.so";
+    return "libomxpluginfroyo.so";
   }
   else if (version < 8) {
     // Below Froyo not supported
     return nullptr;
   }
 
   // Default libomxplugin for non-gingerbread devices
-  return "lib/libomxplugin.so";
+  return "libomxplugin.so";
 
 #elif defined(ANDROID) && defined(MOZ_WIDGET_GONK)
   return "libomxplugin.so";
 #else
   return nullptr;
 #endif
 }
 
 MediaPluginHost::MediaPluginHost() {
   MOZ_COUNT_CTOR(MediaPluginHost);
 
   const char* name = GetOmxLibraryName();
   ALOG("Loading OMX Plugin: %s", name ? name : "nullptr");
   if (name) {
-    PRLibrary *lib = PR_LoadLibrary(name);
+    char *path = PR_GetLibraryFilePathname("libxul.so", (PRFuncPtr) GetOmxLibraryName);
+    PRLibrary *lib = NULL;
+    if (path) {
+      nsAutoCString libpath(path);
+      PR_Free(path);
+      int32_t slash = libpath.RFindChar('/');
+      if (slash != kNotFound) {
+        libpath.Truncate(slash + 1);
+        libpath.Append(name);
+        lib = PR_LoadLibrary(libpath.get());
+      }
+    }
+    if (!lib)
+      lib = PR_LoadLibrary(name);
+
     if (lib) {
       Manifest *manifest = static_cast<Manifest *>(PR_FindSymbol(lib, "MPAPI_MANIFEST"));
       if (manifest) {
         mPlugins.AppendElement(manifest);
         ALOG("OMX plugin successfully loaded");
      }
     }
   }
--- a/toolkit/mozapps/installer/packager.mk
+++ b/toolkit/mozapps/installer/packager.mk
@@ -342,29 +342,27 @@ INNER_ROBOCOP_PACKAGE= \
   $(JARSIGNER) $(_ABS_DIST)/robocop-raw.apk && \
   $(ZIPALIGN) -f -v 4 $(_ABS_DIST)/robocop-raw.apk $(_ABS_DIST)/robocop.apk
 endif
 else
 INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Robocop for you'
 endif
 
 ifdef MOZ_OMX_PLUGIN
-OMX_PLUGIN_NAMES = libomxplugin.so libomxplugingb.so libomxplugingb235.so libomxpluginhc.so libomxpluginsony.so libomxpluginfroyo.so
-else
-OMX_PLUGIN_NAMES =
+DIST_FILES += libomxplugin.so libomxplugingb.so libomxplugingb235.so libomxpluginhc.so libomxpluginsony.so libomxpluginfroyo.so
 endif
 
 PKG_SUFFIX      = .apk
 INNER_MAKE_PACKAGE	= \
   $(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) && mv $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib:.so=.sz) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && ) \
   make -C $(GECKO_APP_AP_PATH) gecko.ap_ && \
   cp $(GECKO_APP_AP_PATH)/gecko.ap_ $(_ABS_DIST) && \
   ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
     mkdir -p lib/$(ABI_DIR) && \
-    mv libmozglue.so $(MOZ_CHILD_PROCESS_NAME) $(OMX_PLUGIN_NAMES) lib/$(ABI_DIR) && \
+    mv libmozglue.so $(MOZ_CHILD_PROCESS_NAME) lib/$(ABI_DIR) && \
     rm -f lib.id && \
     for SOMELIB in *.so ; \
     do \
       printf "`basename $$SOMELIB`:`$(_ABS_DIST)/host/bin/file_id $$SOMELIB`\n" >> lib.id ; \
     done && \
     unzip -o $(_ABS_DIST)/gecko.ap_ && \
     rm $(_ABS_DIST)/gecko.ap_ && \
     $(if $(SZIP_LIBRARIES),$(ZIP) -0 $(_ABS_DIST)/gecko.ap_ $(SZIP_LIBRARIES) && ) \
@@ -377,22 +375,16 @@ INNER_MAKE_PACKAGE	= \
   $(ZIPALIGN) -f -v 4 $(_ABS_DIST)/gecko.apk $(PACKAGE) && \
   $(INNER_ROBOCOP_PACKAGE)
 
 INNER_UNMAKE_PACKAGE	= \
   mkdir $(MOZ_PKG_DIR) && \
   pushd $(MOZ_PKG_DIR) && \
   $(UNZIP) $(UNPACKAGE) && \
   mv lib/$(ABI_DIR)/libmozglue.so . && \
-  mv lib/$(ABI_DIR)/libomxplugin.so . && \
-  mv lib/$(ABI_DIR)/libomxplugingb.so . && \
-  mv lib/$(ABI_DIR)/libomxplugingb235.so . && \
-  mv lib/$(ABI_DIR)/libomxpluginhc.so . && \
-  mv lib/$(ABI_DIR)/libomxpluginsony.so . && \
-  mv lib/$(ABI_DIR)/libomxpluginfroyo.so . && \
   mv lib/$(ABI_DIR)/*plugin-container* $(MOZ_CHILD_PROCESS_NAME) && \
   rm -rf lib/$(ABI_DIR) && \
   popd
 endif
 
 ifeq ($(MOZ_PKG_FORMAT),DMG)
 PKG_SUFFIX	= .dmg
 PKG_DMG_FLAGS	=