aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediaimplgstreamer.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-06 04:41:58 -0500
committerJacek Antonelli2009-04-06 04:41:58 -0500
commit87c760f959788e3ec9dc06cbd2207d0242b6a4c9 (patch)
tree3265d96edbb9aba1eefc2744b03baf037e62402a /linden/indra/llmedia/llmediaimplgstreamer.cpp
parentConverted BOOLs to bools in llthread. (diff)
parentAdded libgstdecodebin.so plugin to Mac manifest. (diff)
downloadmeta-impy-87c760f959788e3ec9dc06cbd2207d0242b6a4c9.zip
meta-impy-87c760f959788e3ec9dc06cbd2207d0242b6a4c9.tar.gz
meta-impy-87c760f959788e3ec9dc06cbd2207d0242b6a4c9.tar.bz2
meta-impy-87c760f959788e3ec9dc06cbd2207d0242b6a4c9.tar.xz
Merge branch 'mac-1.1.0' into next
Required substantial portability changes to set_gst_plugin_path(). Conflicts: linden/indra/llmedia/llmediaimplgstreamer.cpp
Diffstat (limited to 'linden/indra/llmedia/llmediaimplgstreamer.cpp')
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp136
1 files changed, 95 insertions, 41 deletions
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 7ae6b02..5ec9eaf 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -60,6 +60,10 @@ extern "C" {
60#include "llgstplaythread.h" 60#include "llgstplaythread.h"
61 61
62 62
63#if LL_DARWIN
64#include <CoreFoundation/CoreFoundation.h> // For CF functions used in set_gst_plugin_path
65#endif
66
63// register this impl with media manager factory 67// register this impl with media manager factory
64static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() ); 68static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
65 69
@@ -223,61 +227,111 @@ bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
223 227
224void LLMediaImplGStreamer::set_gst_plugin_path() 228void LLMediaImplGStreamer::set_gst_plugin_path()
225{ 229{
226 // Only needed for Windows. 230 // Linux sets GST_PLUGIN_PATH in wrapper.sh, not here.
227 // Linux sets in wrapper.sh, Mac sets in Info-Imprudence.plist 231#if LL_WINDOWS || LL_DARWIN
228#ifdef LL_WINDOWS
229 232
230 char* imp_cwd; 233 std::string imp_dir = "";
231 234
232 // Get the current working directory: 235 // Get the current working directory:
233 imp_cwd = _getcwd(NULL,0); 236#if LL_WINDOWS
237 char* raw_dir;
238 raw_dir = _getcwd(NULL,0);
239 if( raw_dir != NULL )
240 {
241 imp_dir = std::string( raw_dir );
242 }
243#elif LL_DARWIN
244 CFBundleRef main_bundle = CFBundleGetMainBundle();
245 if( main_bundle != NULL )
246 {
247 CFURLRef bundle_url = CFBundleCopyBundleURL( main_bundle );
248 if( bundle_url != NULL )
249 {
250 #ifndef MAXPATHLEN
251 #define MAXPATHLEN 1024
252 #endif
253 char raw_dir[MAXPATHLEN];
254 if( CFURLGetFileSystemRepresentation( bundle_url, true, (UInt8 *)raw_dir, MAXPATHLEN) )
255 {
256 imp_dir = std::string( raw_dir ) + "/Contents/MacOS/";
257 }
258 CFRelease(bundle_url);
259 }
260 }
261#endif
262
263 if( imp_dir == "" )
264 {
265 LL_WARNS("MediaImpl") << "Could not get application directory, not setting GST_PLUGIN_PATH."
266 << LL_ENDL;
267 return;
268 }
234 269
235 if(imp_cwd == NULL) 270 LL_DEBUGS("MediaImpl") << "Imprudence is installed at "
271 << imp_dir << LL_ENDL;
272
273 // ":" on Mac and 'Nix, ";" on Windows
274 std::string separator = G_SEARCHPATH_SEPARATOR_S;
275
276 // Grab the current path, if it's set.
277 std::string old_plugin_path = "";
278 char *old_path = getenv("GST_PLUGIN_PATH");
279 if(old_path == NULL)
236 { 280 {
237 LL_DEBUGS("MediaImpl") << "_getcwd failed, not setting GST_PLUGIN_PATH." 281 LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH."
238 << LL_ENDL; 282 << LL_ENDL;
239 } 283 }
240 else 284 else
241 { 285 {
242 LL_DEBUGS("MediaImpl") << "Imprudence is installed at " 286 old_plugin_path = separator + std::string( old_path );
243 << imp_cwd << LL_ENDL; 287 }
244 288
245 // Grab the current path, if it's set.
246 std::string old_plugin_path = "";
247 char *old_path = getenv("GST_PLUGIN_PATH");
248 if(old_path == NULL)
249 {
250 LL_DEBUGS("MediaImpl") << "Did not find user-set GST_PLUGIN_PATH."
251 << LL_ENDL;
252 }
253 else
254 {
255 old_plugin_path = ";" + std::string( old_path );
256 }
257 289
290 // Search both Imprudence and Imprudence\lib\gstreamer-plugins.
291 // But we also want to search the path the user has set, if any.
292 std::string plugin_path =
293 "GST_PLUGIN_PATH=" +
294 imp_dir + separator +
295#if LL_WINDOWS
296 imp_dir + "\\lib\\gstreamer-plugins" +
297#elif LL_DARWIN
298 imp_dir + "/../Resources/lib/gstreamer-plugins" +
299#endif
300 old_plugin_path;
258 301
259 // Search both Imprudence and Imprudence\lib\gstreamer-plugins. 302 int put_result;
260 // If those fail, search the path the user has set, if any.
261 std::string plugin_path =
262 "GST_PLUGIN_PATH=" +
263 std::string(imp_cwd) + "\\lib\\gstreamer-plugins;" +
264 std::string(imp_cwd) +
265 old_plugin_path;
266 303
267 // Place GST_PLUGIN_PATH in the environment settings for imprudence.exe 304 // Place GST_PLUGIN_PATH in the environment settings
268 // Returns 0 on success 305#if LL_WINDOWS
269 if(_putenv( (char*)plugin_path.c_str() )) 306 put_result = _putenv( (char*)plugin_path.c_str() );
270 { 307#elif LL_DARWIN
271 LL_WARNS("MediaImpl") << "Setting environment variable failed!" << LL_ENDL; 308 put_result = putenv( (char*)plugin_path.c_str() );
272 } 309#endif
273 else 310
274 { 311 if( put_result == -1 )
275 LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to " 312 {
276 << getenv("GST_PLUGIN_PATH") << LL_ENDL; 313 LL_WARNS("MediaImpl") << "Setting GST_PLUGIN_PATH failed!" << LL_ENDL;
277 } 314 }
315 else
316 {
317 LL_DEBUGS("MediaImpl") << "GST_PLUGIN_PATH set to "
318 << getenv("GST_PLUGIN_PATH") << LL_ENDL;
278 } 319 }
320
321 // Don't load system plugins. We only want to use ours, to avoid conflicts.
322#if LL_WINDOWS
323 put_result = _putenv( "GST_PLUGIN_SYSTEM_PATH=\"\"" );
324#elif LL_DARWIN
325 put_result = putenv( "GST_PLUGIN_SYSTEM_PATH=\"\"" );
326#endif
279 327
280#endif //LL_WINDOWS 328 if( put_result == -1 )
329 {
330 LL_WARNS("MediaImpl") << "Setting GST_PLUGIN_SYSTEM_PATH=\"\" failed!"
331 << LL_ENDL;
332 }
333
334#endif // LL_WINDOWS || LL_DARWIN
281} 335}
282 336
283 337