summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 20:50:29 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 20:50:29 +0000
commitbf557e1bbabd298e06e57b2345f96a3fec657f34 (patch)
tree0cb2a13165718213256161bcb3dead8fd73f2fd7 /chrome/renderer
parent774a996a8235bd91dbbdaf6418ad405810f3be5d (diff)
downloadchromium_src-bf557e1bbabd298e06e57b2345f96a3fec657f34.zip
chromium_src-bf557e1bbabd298e06e57b2345f96a3fec657f34.tar.gz
chromium_src-bf557e1bbabd298e06e57b2345f96a3fec657f34.tar.bz2
Dynamically load FFmpeg DLLs if present and --enable-video is on.
If any of the DLLs fail to load or are not present, video is disabled. Review URL: http://codereview.chromium.org/24025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_process.cc40
1 files changed, 37 insertions, 3 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc
index 8cec986..80ec5fb 100644
--- a/chrome/renderer/render_process.cc
+++ b/chrome/renderer/render_process.cc
@@ -29,6 +29,42 @@
#include "chrome/renderer/render_view.h"
#include "webkit/glue/webkit_glue.h"
+// Attempts to load FFmpeg before engaging the sandbox. Returns true if all
+// libraries were loaded successfully, false otherwise.
+static bool LoadFFmpeg() {
+#if defined(OS_WIN)
+ int path_keys[] = {
+ chrome::FILE_LIBAVCODEC,
+ chrome::FILE_LIBAVFORMAT,
+ chrome::FILE_LIBAVUTIL
+ };
+ HMODULE libs[arraysize(path_keys)] = {NULL};
+ for (size_t i = 0; i < arraysize(path_keys); ++i) {
+ std::wstring path;
+ if (!PathService::Get(path_keys[i], &path))
+ break;
+ libs[i] = LoadLibrary(path.c_str());
+ if (!libs[i])
+ break;
+ }
+
+ // Check that we loaded all libraries successfully.
+ if (libs[arraysize(libs)-1])
+ return true;
+
+ // Free any loaded libraries if we weren't successful.
+ for (size_t i = 0; i < arraysize(libs) && libs[i] != NULL; ++i) {
+ FreeLibrary(libs[i]);
+ }
+ return false;
+#else
+ // TODO(port): Need to handle loading FFmpeg on non-Windows platforms.
+ NOTIMPLEMENTED();
+ return false;
+#endif
+}
+
+//-----------------------------------------------------------------------------
RenderProcess::RenderProcess()
: ChildProcess(new RenderThread()),
@@ -122,8 +158,7 @@ void RenderProcess::Init() {
#endif
}
- if (command_line.HasSwitch(switches::kEnableVideo)) {
- // TODO(scherkus): check for any DLL dependencies.
+ if (command_line.HasSwitch(switches::kEnableVideo) && LoadFFmpeg()) {
webkit_glue::SetMediaPlayerAvailable(true);
}
}
@@ -269,4 +304,3 @@ void RenderProcess::ClearTransportDIBCache() {
}
}
}
-