From 07d3c901ab84c20b7f50f27169650c024aa7bcd1 Mon Sep 17 00:00:00 2001
From: Andras Becsi <andras.becsi@digia.com>
Date: Wed, 22 Jan 2014 16:18:37 +0100
Subject: [PATCH] Fix html5 video

Deploy the built ffmpegsumo library and make chromium find it
by overriding the content::DIR_MEDIA_LIBS path with the deploy
location.
We deploy the plugin to $$[QT_INSTALL_PLUGINS]/qtwebengine.

Change-Id: I0aeb37fccd2af62b23f8e6405041655e1f66b7aa
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
---
 src/core/content_main_delegate_qt.cpp |  2 ++
 src/core/core.pro                     | 14 +++++++++++++-
 src/core/web_engine_library_info.cpp  |  6 ++++++
 src/core/web_engine_library_info.h    |  1 +
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 8fe2f3378..c17459fd9 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -42,6 +42,7 @@
 #include "content_main_delegate_qt.h"
 
 #include "base/path_service.h"
+#include "content/public/common/content_paths.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/ui_base_paths.h"
 #include "ui/base/resource/resource_bundle.h"
@@ -62,6 +63,7 @@ static base::StringPiece PlatformResourceProvider(int key) {
 void ContentMainDelegateQt::PreSandboxStartup()
 {
     PathService::Override(base::FILE_EXE, WebEngineLibraryInfo::subProcessPath());
+    PathService::Override(content::DIR_MEDIA_LIBS, WebEngineLibraryInfo::pluginsPath());
     PathService::Override(ui::DIR_LOCALES, WebEngineLibraryInfo::localesPath());
 
     net::NetModule::SetResourceProvider(PlatformResourceProvider);
diff --git a/src/core/core.pro b/src/core/core.pro
index bd228c20a..c5fe808a6 100644
--- a/src/core/core.pro
+++ b/src/core/core.pro
@@ -28,5 +28,17 @@ resources.files = $$REPACK_DIR/qtwebengine_resources.pak
 resources.CONFIG += no_check_exist
 resources.path = $$[QT_INSTALL_DATA]
 
-INSTALLS += locales resources
+PLUGIN_EXTENSION = .so
+PLUGIN_PREFIX = lib
+macx: PLUGIN_PREFIX =
+win32 {
+    PLUGIN_EXTENSION = .dll
+    PLUGIN_PREFIX =
+}
+
+plugins.files = $$getOutDir()/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_EXTENSION}
+plugins.CONFIG += no_check_exist
+plugins.path = $$[QT_INSTALL_PLUGINS]/qtwebengine
+
+INSTALLS += locales resources plugins
 
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index b996297ff..a6b7c5d8d 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -86,6 +86,12 @@ static QString location(QLibraryInfo::LibraryLocation path)
     return QLibraryInfo::location(path);
 }
 
+base::FilePath WebEngineLibraryInfo::pluginsPath()
+{
+    QString path = location(QLibraryInfo::PluginsPath) % QDir::separator() % QStringLiteral("qtwebengine");
+    return base::FilePath(toFilePathString(path));
+}
+
 base::FilePath WebEngineLibraryInfo::subProcessPath()
 {
     static bool initialized = false;
diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h
index 0ad88b90d..a2b3fab31 100644
--- a/src/core/web_engine_library_info.h
+++ b/src/core/web_engine_library_info.h
@@ -47,6 +47,7 @@
 class WebEngineLibraryInfo {
 public:
     static base::FilePath subProcessPath();
+    static base::FilePath pluginsPath();
     static base::FilePath localesPath();
     static base::FilePath repackedResourcesPath();
 };
-- 
GitLab