diff options
author | Jacek Antonelli | 2009-03-29 22:24:30 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-03-29 22:24:30 -0500 |
commit | 26c2ddb4a16030d48a763325ff9c492c3618f39b (patch) | |
tree | 58aaf57d59d574f03950356e4379e2cbec6a54ff /linden/indra | |
parent | Merge commit 'origin/gst-revamp' into mac-1.1.0 (diff) | |
download | meta-impy-26c2ddb4a16030d48a763325ff9c492c3618f39b.zip meta-impy-26c2ddb4a16030d48a763325ff9c492c3618f39b.tar.gz meta-impy-26c2ddb4a16030d48a763325ff9c492c3618f39b.tar.bz2 meta-impy-26c2ddb4a16030d48a763325ff9c492c3618f39b.tar.xz |
Improved set_gst_plugin_path, now sets path on Mac too.
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/llmedia/llmediaimplgstreamer.cpp | 103 |
1 files changed, 67 insertions, 36 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index 9a51b7f..20b89f5 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp | |||
@@ -47,6 +47,10 @@ extern "C" { | |||
47 | #include "llerror.h" | 47 | #include "llerror.h" |
48 | #include "linden_common.h" | 48 | #include "linden_common.h" |
49 | 49 | ||
50 | #if LL_DARWIN | ||
51 | #include <CoreFoundation/CoreFoundation.h> // For CF functions used in set_gst_plugin_path | ||
52 | #endif | ||
53 | |||
50 | // register this impl with media manager factory | 54 | // register this impl with media manager factory |
51 | static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); | 55 | static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); |
52 | 56 | ||
@@ -203,55 +207,82 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data) | |||
203 | 207 | ||
204 | void LLMediaImplGStreamer::set_gst_plugin_path() | 208 | void LLMediaImplGStreamer::set_gst_plugin_path() |
205 | { | 209 | { |
206 | // Only needed for Windows. | 210 | // Linux sets GST_PLUGIN_PATH in wrapper.sh, not here. |
207 | // Linux sets in wrapper.sh, Mac sets in Info-Imprudence.plist | 211 | #if LL_WINDOWS || LL_DARWIN |
208 | #ifdef LL_WINDOWS | ||
209 | 212 | ||
210 | char* imp_cwd; | 213 | std::string imp_dir = ""; |
211 | 214 | ||
212 | // Get the current working directory: | 215 | // Get the current working directory: |
213 | imp_cwd = _getcwd(NULL,0); | 216 | #if LL_WINDOWS |
214 | 217 | char* raw_dir; | |
215 | if(imp_cwd == NULL) | 218 | raw_dir = _getcwd(NULL,0); |
219 | if( raw_dir != NULL ) | ||
216 | { | 220 | { |
217 | LL_DEBUGS("LLMediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." | 221 | imp_dir = std::string( raw_dir ); |
218 | << LL_ENDL; | ||
219 | } | 222 | } |
220 | else | 223 | #elif LL_DARWIN |
224 | CFBundleRef main_bundle = CFBundleGetMainBundle(); | ||
225 | if( main_bundle != NULL ) | ||
221 | { | 226 | { |
222 | LL_DEBUGS("LLMediaImpl") << "Imprudence is installed at " | 227 | CFURLRef bundle_url = CFBundleCopyBundleURL( main_bundle ); |
223 | << imp_cwd << LL_ENDL; | 228 | if( bundle_url != NULL ) |
224 | |||
225 | // Grab the current path, if it's set. | ||
226 | std::string old_plugin_path = ""; | ||
227 | char *old_path = getenv("GST_PLUGIN_PATH"); | ||
228 | if(old_path == NULL) | ||
229 | { | ||
230 | LL_DEBUGS("LLMediaImpl") << "Did not find user-set GST_PLUGIN_PATH." | ||
231 | << LL_ENDL; | ||
232 | } | ||
233 | else | ||
234 | { | 229 | { |
235 | old_plugin_path = std::string( old_path ) + ":"; | 230 | #ifndef MAXPATHLEN |
231 | #define MAXPATHLEN 1024 | ||
232 | #endif | ||
233 | char raw_dir[MAXPATHLEN]; | ||
234 | if( CFURLGetFileSystemRepresentation( bundle_url, true, (UInt8 *)raw_dir, MAXPATHLEN) ) | ||
235 | { | ||
236 | imp_dir = std::string( raw_dir ) + "/Contents/MacOS/"; | ||
237 | } | ||
238 | CFRelease(bundle_url); | ||
236 | } | 239 | } |
240 | } | ||
241 | #endif | ||
237 | 242 | ||
243 | if( imp_dir == "" ) | ||
244 | { | ||
245 | LL_DEBUGS("MediaImpl") << "Could not get application directory, not setting GST_PLUGIN_PATH." | ||
246 | << LL_ENDL; | ||
247 | return; | ||
248 | } | ||
238 | 249 | ||
239 | // Search both Imprudence and Imprudence\lib\gstreamer-plugins. | 250 | LL_DEBUGS("MediaImpl") << "Imprudence is installed at " |
240 | // But we also want to first search the path the user has set, if any. | 251 | << imp_dir << LL_ENDL; |
241 | std::string plugin_path = | ||
242 | "GST_PLUGIN_PATH=" + | ||
243 | old_plugin_path + | ||
244 | std::string(imp_cwd) + ":" + | ||
245 | std::string(imp_cwd) + "\\lib\\gstreamer-plugins"; | ||
246 | |||
247 | // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe | ||
248 | putenv( (char*)plugin_path.c_str() ); | ||
249 | 252 | ||
250 | LL_DEBUGS("LLMediaImpl") << "GST_PLUGIN_PATH set to " | 253 | // Grab the current path, if it's set. |
251 | << getenv("GST_PLUGIN_PATH") << LL_ENDL; | 254 | std::string old_plugin_path = ""; |
255 | char *old_path = getenv("GST_PLUGIN_PATH"); | ||
256 | if(old_path == NULL) | ||
257 | { | ||
258 | LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH." | ||
259 | << LL_ENDL; | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | old_plugin_path = std::string( old_path ) + ":"; | ||
252 | } | 264 | } |
253 | 265 | ||
254 | #endif //LL_WINDOWS | 266 | |
267 | // Search both Imprudence and Imprudence\lib\gstreamer-plugins. | ||
268 | // But we also want to first search the path the user has set, if any. | ||
269 | std::string plugin_path = | ||
270 | "GST_PLUGIN_PATH=" + | ||
271 | old_plugin_path + | ||
272 | imp_dir + ":" + | ||
273 | #if LL_WINDOWS | ||
274 | imp_dir + "\\lib\\gstreamer-plugins"; | ||
275 | #elif LL_DARWIN | ||
276 | imp_dir + "/../Resources/lib/gstreamer-plugins"; | ||
277 | #endif | ||
278 | |||
279 | // Place GST_PLUGIN_PATH in the environment settings | ||
280 | putenv( (char*)plugin_path.c_str() ); | ||
281 | |||
282 | LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to " | ||
283 | << getenv("GST_PLUGIN_PATH") << LL_ENDL; | ||
284 | |||
285 | #endif // LL_WINDOWS || LL_DARWIN | ||
255 | } | 286 | } |
256 | 287 | ||
257 | 288 | ||