ardour
video_tool_paths.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010-2013 Paul Davis
3  Author: Robin Gareus <robin@gareus.org>
4 
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.
9 
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.
14 
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.
18 
19 */
20 #include <string>
21 #include <gtkmm.h>
22 
23 #ifdef PLATFORM_WINDOWS
24 #include <windows.h>
25 #include <shlobj.h> // CSIDL_*
27 #endif
28 
29 #include "pbd/file_utils.h"
30 #include "video_tool_paths.h"
31 #include "i18n.h"
32 
33 using namespace PBD;
34 
35 #ifdef PLATFORM_WINDOWS
36 
37 static bool
38 windows_install_dir (const char *regkey, std::string &rv) {
39  HKEY key;
40  DWORD size = PATH_MAX;
41  char tmp[PATH_MAX+1];
42 
43  if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key))
44  && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
45  )
46  {
47  rv = Glib::locale_to_utf8(tmp);
48  return true;
49  }
50 
51  if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key))
52  && (ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
53  )
54  {
55  rv = Glib::locale_to_utf8(tmp);
56  return true;
57  }
58 
59  return false;
60 }
61 #endif
62 
63 bool
65 {
66 
67 #ifdef PLATFORM_WINDOWS
68  std::string reg;
69  const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
70 #endif
71 
72  harvid_exe = "";
73 
74  std::string icsd_file_path;
75  if (find_file (PBD::Searchpath(Glib::getenv("PATH")), X_("harvid"), icsd_file_path)) {
76  harvid_exe = icsd_file_path;
77  }
78 #ifdef PLATFORM_WINDOWS
79  else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
80  {
81  harvid_exe = g_build_filename(reg.c_str(), "harvid", "harvid.exe", NULL);
82  }
83  else if ( windows_install_dir("Software\\RSS\\harvid", reg))
84  {
85  harvid_exe = g_build_filename(reg.c_str(), "harvid.exe", NULL);
86  }
87  else if (program_files && Glib::file_test(g_build_filename(program_files, "harvid", "harvid.exe", NULL), Glib::FILE_TEST_EXISTS))
88  {
89  harvid_exe = g_build_filename(program_files, "harvid", "harvid.exe", NULL);
90  }
91  else if (Glib::file_test(X_("C:\\Program Files\\harvid\\harvid.exe"), Glib::FILE_TEST_EXISTS)) {
92  harvid_exe = X_("C:\\Program Files\\harvid\\harvid.exe");
93  }
94 #endif
95  else
96  {
97  return false;
98  }
99  return true;
100 }
101 
102 bool
104 {
105  std::string xjadeo_file_path;
106 #ifdef PLATFORM_WINDOWS
107  std::string reg;
108  const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
109 #endif
110  if (getenv("XJREMOTE")) {
111  xjadeo_exe = getenv("XJREMOTE");
112  } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
113  xjadeo_exe = xjadeo_file_path;
114  } else if (find_file (Searchpath(Glib::getenv("PATH")), X_("xjadeo"), xjadeo_file_path)) {
115  xjadeo_exe = xjadeo_file_path;
116  }
117 #ifdef __APPLE__
118  else if (Glib::file_test(X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
119  xjadeo_exe = X_("/Applications/Xjadeo.app/Contents/MacOS/xjadeo");
120  }
121  else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
122  xjadeo_exe = X_("/Applications/Jadeo.app/Contents/MacOS/Jadeo-bin");
123  }
124 #endif
125 #ifdef PLATFORM_WINDOWS
126  else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
127  {
128  xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo", "xjadeo.exe", NULL));
129  }
130  else if ( windows_install_dir("Software\\RSS\\xjadeo", reg))
131  {
132  xjadeo_exe = std::string(g_build_filename(reg.c_str(), "xjadeo.exe", NULL));
133  }
134  else if (program_files && Glib::file_test(g_build_filename(program_files, "xjadeo", "xjadeo.exe", NULL), Glib::FILE_TEST_EXISTS))
135  {
136  xjadeo_exe = std::string(g_build_filename(program_files, "xjadeo", "xjadeo.exe", NULL));
137  }
138  else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjadeo.exe"), Glib::FILE_TEST_EXISTS)) {
139  xjadeo_exe = X_("C:\\Program Files\\xjadeo\\xjadeo.exe");
140  }
141 #endif
142  else {
143  xjadeo_exe = X_("");
144  return false;
145  }
146  return true;
147 }
148 
149 bool
150 ArdourVideoToolPaths::transcoder_exe (std::string &ffmpeg_exe, std::string &ffprobe_exe)
151 {
152 #ifdef PLATFORM_WINDOWS
153  std::string reg;
154  const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES);
155 #endif
156 
157  ffmpeg_exe = X_("");
158  ffprobe_exe = X_("");
159 
160  std::string ff_file_path;
161  if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffmpeg_harvid"), ff_file_path)) {
162  ffmpeg_exe = ff_file_path;
163  }
164 #ifdef PLATFORM_WINDOWS
165  else if ( windows_install_dir("Software\\" PROGRAM_NAME "\\v" PROGRAM_VERSION "\\video", reg))
166  {
167  ffmpeg_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffmpeg.exe"), NULL);
168  ffprobe_exe = g_build_filename(reg.c_str(), X_("harvid"), X_("ffprobe.exe"), NULL);
169  }
170  else if ( windows_install_dir("Software\\RSS\\harvid", reg))
171  {
172  ffmpeg_exe = g_build_filename(reg.c_str(), X_("ffmpeg.exe"), NULL);
173  ffprobe_exe = g_build_filename(reg.c_str(), X_("ffprobe.exe"), NULL);
174  }
175 
176  if (Glib::file_test(ffmpeg_exe, Glib::FILE_TEST_EXISTS)) {
177  ;
178  }
179  else if (program_files && Glib::file_test(g_build_filename(program_files, "harvid", "ffmpeg.exe", NULL), Glib::FILE_TEST_EXISTS)) {
180  ffmpeg_exe = g_build_filename(program_files, "harvid", "ffmpeg.exe", NULL);
181  }
182  else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe"), Glib::FILE_TEST_EXISTS)) {
183  ffmpeg_exe = X_("C:\\Program Files\\ffmpeg\\ffmpeg.exe");
184  } else {
185  ffmpeg_exe = X_("");
186  }
187 #endif
188 
189  if (find_file (Searchpath(Glib::getenv("PATH")), X_("ffprobe_harvid"), ff_file_path)) {
190  ffprobe_exe = ff_file_path;
191  }
192 #ifdef PLATFORM_WINDOWS
193  if (Glib::file_test(ffprobe_exe, Glib::FILE_TEST_EXISTS)) {
194  ;
195  }
196  else if (program_files && Glib::file_test(g_build_filename(program_files, "harvid", "ffprobe.exe", NULL), Glib::FILE_TEST_EXISTS)) {
197  ffprobe_exe = g_build_filename(program_files, "harvid", "ffprobe.exe", NULL);
198  }
199  else if (Glib::file_test(X_("C:\\Program Files\\ffmpeg\\ffprobe.exe"), Glib::FILE_TEST_EXISTS)) {
200  ffprobe_exe = X_("C:\\Program Files\\ffmpeg\\ffprobe.exe");
201  } else {
202  ffprobe_exe = X_("");
203  }
204 #endif
205 
206  if (ffmpeg_exe.empty() || ffprobe_exe.empty()) {
207  return false;
208  }
209  return true;
210 }
bool xjadeo_exe(std::string &xjadeo_exe)
bool harvid_exe(std::string &harvid_exe)
bool transcoder_exe(std::string &ffmpeg_exe, std::string &ffprobe_exe)
LIBPBD_API char * get_win_special_folder(int csidl)
bool find_file(const Searchpath &search_path, const string &filename, std::string &result)
Definition: file_utils.cc:187
#define PATH_MAX
Definition: lv2_plugin.h:34
#define X_(Text)
Definition: i18n.h:13
Definition: debug.h:30