2 Copyright (C) 2010-2013 Paul Davis
3 Author: Robin Gareus <robin@gareus.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifdef PLATFORM_WINDOWS
25 #include <shlobj.h> // CSIDL_*
26 #include "pbd/windows_special_dirs.h"
29 #include "pbd/file_utils.h"
30 #include "ui_config.h"
31 #include "video_tool_paths.h"
36 #ifdef PLATFORM_WINDOWS
39 windows_install_dir (const char *regkey, std::string &rv) {
41 DWORD size = PATH_MAX;
44 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key))
45 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
48 rv = Glib::locale_to_utf8(tmp);
52 if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key))
53 && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
56 rv = Glib::locale_to_utf8(tmp);
65 ArdourVideoToolPaths::harvid_exe (std::string &harvid_exe)
68 #ifdef PLATFORM_WINDOWS
70 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
75 std::string icsd_file_path;
76 if (find_file (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
77 harvid_exe = icsd_file_path;
79 #ifdef PLATFORM_WINDOWS
80 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
82 harvid_exe = g_build_filename(reg.c_str(), "harvid", "harvid.exe", NULL);
84 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
86 harvid_exe = g_build_filename(reg.c_str(), "harvid.exe", NULL);
88 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL), Glib::FILE_TEST_EXISTS))
90 harvid_exe = g_build_filename(program_files.c_str(), "harvid", "harvid.exe", NULL);
92 else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) {
93 harvid_exe = X_("C:\\Program Files\\harvid\\harvid.exe");
104 ArdourVideoToolPaths::xjadeo_exe (std::string &xjadeo_exe)
106 std::string xjadeo_file_path;
107 #ifdef PLATFORM_WINDOWS
109 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
113 if (getenv("XJREMOTE")) {
114 xjadeo_exe = getenv("XJREMOTE");
116 } else if (!UIConfiguration::instance().get_xjadeo_binary().empty()
117 && Glib::file_test (UIConfiguration::instance().get_xjadeo_binary() + "/Contents/MacOS/xjadeo", Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
118 xjadeo_exe = UIConfiguration::instance().get_xjadeo_binary() + "/Contents/MacOS/xjadeo";
120 } else if (!UIConfiguration::instance().get_xjadeo_binary().empty()
121 && Glib::file_test (UIConfiguration::instance().get_xjadeo_binary(), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
122 xjadeo_exe = UIConfiguration::instance().get_xjadeo_binary();
123 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
124 xjadeo_exe = xjadeo_file_path;
125 } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjadeo"), xjadeo_file_path)) {
126 xjadeo_exe = xjadeo_file_path;
129 else if (Glib::file_test(X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
130 xjadeo_exe = X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo");
132 else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
133 xjadeo_exe = X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin");
136 #ifdef PLATFORM_WINDOWS
137 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
139 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo", "xjadeo.exe", NULL));
141 else if ( windows_install_dir("Software\\RSS\\xjadeo", reg))
143 xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo.exe", NULL));
145 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL), Glib::FILE_TEST_EXISTS))
147 xjadeo_exe = std::string(g_build_filename(program_files.c_str(), "xjadeo", "xjadeo.exe", NULL));
149 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjadeo.exe"), Glib::FILE_TEST_EXISTS)) {
150 xjadeo_exe = X_("C:\\Program Files\\xjadeo\\xjadeo.exe");
154 return (!xjadeo_exe.empty() && Glib::file_test(xjadeo_exe, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE));
158 ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe)
160 #ifdef PLATFORM_WINDOWS
162 std::string program_files = PBD::get_win_special_folder_path (CSIDL_PROGRAM_FILES);
166 ffprobe_exe = X_("");
168 std::string ff_file_path;
169 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) {
170 ffmpeg_exe = ff_file_path;
172 #ifdef PLATFORM_WINDOWS
173 else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
175 ffmpeg_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffmpeg.exe"), NULL);
176 ffprobe_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffprobe.exe"), NULL);
178 else if ( windows_install_dir("Software\\RSS\\harvid", reg))
180 ffmpeg_exe = g_build_filename(reg.c_str(), X_("ffmpeg.exe"), NULL);
181 ffprobe_exe = g_build_filename(reg.c_str(), X_("ffprobe.exe"), NULL);
184 if (Glib::file_test(ffmpeg_exe, Glib::FILE_TEST_EXISTS)) {
187 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL), Glib::FILE_TEST_EXISTS)) {
188 ffmpeg_exe = g_build_filename(program_files.c_str(), "harvid", "ffmpeg.exe", NULL);
190 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) {
191 ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
197 if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) {
198 ffprobe_exe = ff_file_path;
200 #ifdef PLATFORM_WINDOWS
201 if (Glib::file_test(ffprobe_exe, Glib::FILE_TEST_EXISTS)) {
204 else if (!program_files.empty() && Glib::file_test(g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL), Glib::FILE_TEST_EXISTS)) {
205 ffprobe_exe = g_build_filename(program_files.c_str(), "harvid", "ffprobe.exe", NULL);
207 else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) {
208 ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe");
210 ffprobe_exe = X_("");
214 if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {