sbGStreamerService.cpp
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2010 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 #include "sbGStreamerService.h"
27 #include <gst/pbutils/descriptions.h>
28 #include <glib.h>
29 
30 #include <sbLibraryLoaderUtils.h>
31 
32 #include <nsIEnvironment.h>
33 #include <nsIProperties.h>
34 #include <nsIFile.h>
35 #include <nsILocalFile.h>
36 #include <nsStringGlue.h>
37 #include <prlog.h>
38 #include <prenv.h>
39 #include <nsServiceManagerUtils.h>
40 #include <nsDirectoryServiceUtils.h>
41 #include <nsAppDirectoryServiceDefs.h>
42 #include <nsComponentManagerUtils.h>
43 #include <nsThreadUtils.h>
44 #include <nsXULAppAPI.h>
45 #include <nsISimpleEnumerator.h>
46 #include <nsIPrefBranch.h>
47 
48 #include <sbStringUtils.h>
49 
50 #if XP_WIN
51 #include <windows.h>
52 #endif
53 
54 #define GSTREAMER_COMPREG_LAST_MODIFIED_TIME_PREF \
55  "songbird.mediacore.gstreamer.compreg_last_modified_time"
56 
63 #ifdef PR_LOGGING
64 
65 static PRLogModuleInfo* gGStreamerService =
66  PR_NewLogModule("sbGStreamerService");
67 
68 #define LOG(args) \
69  if (gGStreamerService) \
70  PR_LOG(gGStreamerService, PR_LOG_WARNING, args)
71 
72 #define TRACE(args) \
73  if (gGStreamerService) \
74  PR_LOG(gGStreamerService, PR_LOG_DEBUG, args)
75 
76 #else /* PR_LOGGING */
77 
78 #define LOG(args) /* nothing */
79 #define TRACE(args) /* nothing */
80 
81 #endif /* PR_LOGGING */
82 
83 static const char *
84 get_rank_name (gint rank)
85 {
86  switch (rank) {
87  case GST_RANK_NONE:
88  return "none";
89  case GST_RANK_MARGINAL:
90  return "marginal";
91  case GST_RANK_SECONDARY:
92  return "secondary";
93  case GST_RANK_PRIMARY:
94  return "primary";
95  default:
96  return "unknown";
97  }
98 }
99 
101 
103 {
104  LOG(("sbGStreamerService[0x%.8x] - ctor", this));
105 }
106 
107 sbGStreamerService::~sbGStreamerService()
108 {
109  LOG(("sbGStreamerService[0x%.8x] - dtor", this));
110 }
111 
117 nsresult SetEnvVar(const nsAString& aName, const nsAString& aValue)
118 {
119  #if XP_WIN
120  // on Windows, we need to go through the OS APIs to be able to set Unicode
121  // environment variables. See bmo bug 476739.
122  BOOL result;
123  if (aValue.IsVoid()) {
124  result = ::SetEnvironmentVariableW(PromiseFlatString(aName).get(), NULL);
125  } else {
126  result = ::SetEnvironmentVariableW(PromiseFlatString(aName).get(),
127  PromiseFlatString(aValue).get());
128  }
129  return (result != 0) ? NS_OK : NS_ERROR_FAILURE;
130  #else
131  nsCString env;
132  CopyUTF16toUTF8(aName, env);
133  env.AppendLiteral("=");
134  env.Append(NS_ConvertUTF16toUTF8(aValue));
135  PRInt32 length = env.Length();
136  char* buf = (char*)NS_Alloc(length + 1);
137  if (!buf) {
138  return NS_ERROR_OUT_OF_MEMORY;
139  }
140  memcpy(buf, env.get(), length);
141  buf[length] = '\0';
142  PRStatus status = PR_SetEnv(buf);
143  // intentionally leak buf
144  return (PR_SUCCESS == status) ? NS_OK : NS_ERROR_FAILURE;
145  #endif
146 }
147 
148 // sbIGStreamerService
149 nsresult
151 {
152  NS_ASSERTION(NS_IsMainThread(), "Not on main thread");
153 
154  nsresult rv;
155  NS_NAMED_LITERAL_STRING(kGstPluginSystemPath, "GST_PLUGIN_SYSTEM_PATH");
156  NS_NAMED_LITERAL_STRING(kGstRegistry, "GST_REGISTRY");
157  NS_NAMED_LITERAL_STRING(kGstPluginPath, "GST_PLUGIN_PATH");
158  PRBool noSystemPlugins;
159  PRBool systemGst;
160  PRBool hasMore;
161  PRBool first = PR_TRUE;
162  nsString pluginPaths;
163  nsString systemPluginPaths;
164 
165  nsCOMPtr<nsISimpleEnumerator> dirList;
166 
167  nsCOMPtr<nsIEnvironment> envSvc =
168  do_GetService("@mozilla.org/process/environment;1", &rv);
169  NS_ENSURE_SUCCESS(rv, rv);
170 
171  nsCOMPtr<nsIProperties> directorySvc =
172  do_GetService("@mozilla.org/file/directory_service;1", &rv);
173  NS_ENSURE_SUCCESS(rv, rv);
174 
175 #if defined(XP_MACOSX) || defined(XP_WIN)
176  systemGst = PR_FALSE;
177  noSystemPlugins = PR_TRUE;
178 #else
179  // On unix, default to using the bundled gstreamer (plus the system plugins
180  // as a fallback).
181  // If this env var is set, use ONLY the system gstreamer.
182  rv = envSvc->Exists(NS_LITERAL_STRING("SB_GST_SYSTEM"), &systemGst);
183  NS_ENSURE_SUCCESS(rv, rv);
184  // And if this one is set, don't use system plugins
185  rv = envSvc->Exists(NS_LITERAL_STRING("SB_GST_NO_SYSTEM"), &noSystemPlugins);
186  NS_ENSURE_SUCCESS(rv, rv);
187 #endif
188 
189  // We only build parts of the path on gst system builds. For bundled gst:
190  // Build the plugin path. This is from highest-to-lowest priority, so
191  // we prefer our plugins to the system ones (unless overridden by
192  // GST_PLUGIN_PATH).
193  //
194  // We use the following paths:
195  // 1. Plugin directories set by the user using GST_PLUGIN_PATH (if any),
196  // on unix systems (not windows/osx) only.
197  // 2. Extension-provided plugin directories (in no particular order)
198  // 3. Our bundled gst-plugins directory
199  //
200  // Plus the system plugin path on linux:
201  // 4. $HOME/.gstreamer-0.10/plugins
202  // 5. /usr/lib/gstreamer-0.10 or /usr/lib64/gstreamer-0.10
203 
204 #if defined(XP_MACOSX) || defined(XP_WIN)
205  pluginPaths = EmptyString();
206 #else
207  // 1. Read the existing GST_PLUGIN_PATH (if any)
208  PRBool pluginPathExists;
209  rv = envSvc->Exists(kGstPluginPath, &pluginPathExists);
210  NS_ENSURE_SUCCESS(rv, rv);
211  if (pluginPathExists) {
212  rv = envSvc->Get(kGstPluginPath, pluginPaths);
213  NS_ENSURE_SUCCESS(rv, rv);
214  first = PR_FALSE;
215  }
216  else
217  pluginPaths = EmptyString();
218 #endif
219 
220 #ifdef GST_SYSTEM
221  // For system builds, only add our bundled gst-plugins directory
222  nsCOMPtr<nsIFile> pluginDir;
223  rv = directorySvc->Get("resource:app",
224  NS_GET_IID(nsIFile),
225  getter_AddRefs(pluginDir));
226  NS_ENSURE_SUCCESS(rv, rv);
227 
228  rv = pluginDir->Append(NS_LITERAL_STRING("gst-plugins"));
229  NS_ENSURE_SUCCESS(rv, rv);
230 
231  nsString pluginDirStr;
232  rv = pluginDir->GetPath(pluginDirStr);
233  NS_ENSURE_SUCCESS(rv, rv);
234 
235  if (!first)
236  pluginPaths.AppendLiteral(G_SEARCHPATH_SEPARATOR_S);
237  pluginPaths.Append(pluginDirStr);
238 
239  LOG(("sbGStreamerService[0x%.8x] - Setting GST_PLUGIN_PATH=%s", this,
240  NS_LossyConvertUTF16toASCII(pluginPaths).get()));
241  rv = SetEnvVar(kGstPluginPath, pluginPaths);
242  NS_ENSURE_SUCCESS(rv, rv);
243 
244 #else
245 
246  // 2. Add extension-provided plugin directories (if any)
247  rv = directorySvc->Get(XRE_EXTENSIONS_DIR_LIST,
248  NS_GET_IID(nsISimpleEnumerator),
249  getter_AddRefs(dirList));
250  NS_ENSURE_SUCCESS(rv, rv);
251 
252  while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
253  PRBool dirExists;
254  nsCOMPtr<nsISupports> supports;
255  rv = dirList->GetNext(getter_AddRefs(supports));
256  if (NS_FAILED(rv))
257  continue;
258  nsCOMPtr<nsIFile> extensionDir(do_QueryInterface(supports, &rv));
259  if (NS_FAILED(rv))
260  continue;
261 
262  rv = extensionDir->Append(NS_LITERAL_STRING("gst-plugins"));
263  NS_ENSURE_SUCCESS(rv, rv);
264  rv = extensionDir->Exists(&dirExists);
265  NS_ENSURE_SUCCESS(rv, rv);
266 
267  if (dirExists) {
268  nsString dirPath;
269  rv = extensionDir->GetPath(dirPath);
270  NS_ENSURE_SUCCESS(rv, rv);
271 
272  if (!first)
273  pluginPaths.AppendLiteral(G_SEARCHPATH_SEPARATOR_S);
274  pluginPaths.Append(dirPath);
275  first = PR_FALSE;
276 
277  // The extension might also provide dependent libraries that it needs
278  // for the plugin(s) to work. So, load those if there's a special
279  // text file listing what we need to load.
280  PRBool fileExists;
281  nsCOMPtr<nsIFile> dependencyListFile;
282  rv = extensionDir->Clone(getter_AddRefs(dependencyListFile));
283  NS_ENSURE_SUCCESS(rv, rv);
284 
285  rv = dependencyListFile->Append(
286  NS_LITERAL_STRING("dependent-libraries.txt"));
287  NS_ENSURE_SUCCESS(rv, rv);
288 
289  rv = dependencyListFile->Exists(&fileExists);
290  NS_ENSURE_SUCCESS(rv, rv);
291 
292  if (fileExists) {
293  rv = SB_LoadLibraries(dependencyListFile);
294  NS_ENSURE_SUCCESS(rv, rv);
295  }
296  }
297  }
298 
299  // 3. Add our bundled gst-plugins directory
300  nsCOMPtr<nsIFile> pluginDir;
301  rv = directorySvc->Get("resource:app",
302  NS_GET_IID(nsIFile),
303  getter_AddRefs(pluginDir));
304  NS_ENSURE_SUCCESS(rv, rv);
305 
306  rv = pluginDir->Append(NS_LITERAL_STRING("gst-plugins"));
307  NS_ENSURE_SUCCESS(rv, rv);
308 
309  nsString pluginDirStr;
310  rv = pluginDir->GetPath(pluginDirStr);
311  NS_ENSURE_SUCCESS(rv, rv);
312 
313  if (!first)
314  pluginPaths.AppendLiteral(G_SEARCHPATH_SEPARATOR_S);
315  pluginPaths.Append(pluginDirStr);
316 
317  // Remaining steps on unix only
318 #if !defined(XP_MACOSX) && !defined(XP_WIN)
319 
320  if (!noSystemPlugins) {
321  // 4. Add $HOME/.gstreamer-0.10/plugins to system plugin path
322  // Use the same code as gstreamer for this to ensure it's the
323  // same path...
324  char *homeDirPlugins = g_build_filename (g_get_home_dir (),
325  ".gstreamer-0.10", "plugins", NULL);
326  systemPluginPaths = NS_ConvertUTF8toUTF16(homeDirPlugins);
327 
328  // 5. Add /usr/lib/gstreamer-0.10 to system plugin path
329 
330  // There's a bug in GStreamer which can cause registry problems with
331  // renamed plugins. Older versions of decodebin2 were in
332  // 'libgsturidecodebin.so' rather than the current 'libgstdecodebin2.so'.
333  // To avoid this, do not use system plugins if this old plugin file
334  // exists.
335  nsCOMPtr<nsILocalFile> badFile = do_CreateInstance(
336  "@mozilla.org/file/local;1", &rv);
337  NS_ENSURE_SUCCESS(rv, rv);
338 
339  nsString sysLibDir;
340 #ifdef HAVE_64BIT_OS
341  sysLibDir = NS_LITERAL_STRING("/usr/lib64/gstreamer-0.10");
342 #else
343  sysLibDir = NS_LITERAL_STRING("/usr/lib/gstreamer-0.10");
344 #endif
345 
346  nsString badFilePath = sysLibDir;
347  badFilePath.AppendLiteral("/libgsturidecodebin.so");
348 
349  rv = badFile->InitWithPath(badFilePath);
350  NS_ENSURE_SUCCESS(rv, rv);
351 
352  PRBool badFileExists;
353  rv = badFile->Exists(&badFileExists);
354  NS_ENSURE_SUCCESS(rv, rv);
355 
356  if (!badFileExists) {
357  systemPluginPaths.AppendLiteral(G_SEARCHPATH_SEPARATOR_S);
358  systemPluginPaths.Append(sysLibDir);
359  }
360  }
361 #else
362  systemPluginPaths = NS_LITERAL_STRING("");
363 #endif // !defined(XP_MACOSX) && !defined(XP_WIN)
364 
365 
366  LOG(("sbGStreamerService[0x%.8x] - Setting GST_PLUGIN_PATH=%s", this,
367  NS_LossyConvertUTF16toASCII(pluginPaths).get()));
368  rv = SetEnvVar(kGstPluginPath, pluginPaths);
369  NS_ENSURE_SUCCESS(rv, rv);
370 
371  LOG(("sbGStreamerService[0x%.8x] - Setting GST_PLUGIN_SYSTEM_PATH=%s", this,
372  NS_LossyConvertUTF16toASCII(systemPluginPaths).get()));
373  rv = SetEnvVar(kGstPluginSystemPath, systemPluginPaths);
374  NS_ENSURE_SUCCESS(rv, rv);
375 
376 #endif // GST_SYSTEM
377 
378  // Set registry path
379  nsCOMPtr<nsIFile> registryPath;
380  rv = GetGStreamerRegistryFile(getter_AddRefs(registryPath));
381  NS_ENSURE_SUCCESS(rv, rv);
382 
383  nsString registryPathStr;
384  rv = registryPath->GetPath(registryPathStr);
385  NS_ENSURE_SUCCESS(rv, rv);
386 
387  LOG(("sbGStreamerService[0x%.8x] - Setting GST_REGISTRY=%s", this,
388  NS_LossyConvertUTF16toASCII(registryPathStr).get()));
389 
390  rv = SetEnvVar(kGstRegistry, registryPathStr);
391  NS_ENSURE_SUCCESS(rv, rv);
392 
393 #ifdef XP_MACOSX
394  // XXX This is very bad according to edward! But we need it until
395  // http://bugzilla.gnome.org/show_bug.cgi?id=521978
396  // is fixed.
397 
398  gst_registry_fork_set_enabled(FALSE);
399 #endif
400 
401  // Update the gstreamer registry file if needed.
402  UpdateGStreamerRegistryFile();
403 
404  gst_init(NULL, NULL);
405 
406  // Register our custom tags.
408 
409  return NS_OK;
410 }
411 
412 NS_IMETHODIMP
413 sbGStreamerService::Inspect(sbIGStreamerInspectHandler* aHandler)
414 {
415  NS_ENSURE_ARG_POINTER(aHandler);
416  nsresult rv;
417 
418  char libvisual[10] = "libvisual";
419 
420  GList *plugins, *orig_plugins;
421 
422  rv = aHandler->BeginInspect();
423  NS_ENSURE_SUCCESS(rv, rv);
424 
425  orig_plugins = plugins = gst_default_registry_get_plugin_list();
426  while (plugins) {
427  GstPlugin *plugin;
428  plugin = (GstPlugin *) (plugins->data);
429  plugins = g_list_next (plugins);
430 
431  if (g_strcmp0(plugin->desc.name, libvisual) != 0) {
432 
433  nsCString filename;
434  if (plugin->filename) {
435  filename = plugin->filename;
436  }
437  else {
438  filename.SetIsVoid(PR_TRUE);
439  }
440 
441  rv = aHandler->BeginPluginInfo(nsDependentCString(plugin->desc.name),
442  nsDependentCString(plugin->desc.description),
443  filename,
444  nsDependentCString(plugin->desc.version),
445  nsDependentCString(plugin->desc.license),
446  nsDependentCString(plugin->desc.source),
447  nsDependentCString(plugin->desc.package),
448  nsDependentCString(plugin->desc.origin));
449  NS_ENSURE_SUCCESS(rv, rv);
450 
451  GList *features, *orig_features;
452  orig_features = features =
453  gst_registry_get_feature_list_by_plugin(gst_registry_get_default(),
454  plugin->desc.name);
455  while (features) {
456  GstPluginFeature *feature;
457  feature = GST_PLUGIN_FEATURE(features->data);
458 
459  if (g_strcmp0(feature->plugin_name, libvisual) != 0) {
460  if (GST_IS_ELEMENT_FACTORY(feature)) {
461  GstElementFactory *factory;
462  factory = GST_ELEMENT_FACTORY(feature);
463 
464  rv = InspectFactory(factory, aHandler);
465  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "InspectFactory failed");
466  }
467  } else {
468  LOG(("sbGStreamerService[0x%.8x] - Caught libvisual", this));
469  }
470 
471  features = g_list_next(features);
472  }
473 
474  gst_plugin_feature_list_free(orig_features);
475 
476  rv = aHandler->EndPluginInfo();
477  NS_ENSURE_SUCCESS(rv, rv);
478  }
479  }
480 
481  gst_plugin_list_free(orig_plugins);
482 
483  rv = aHandler->EndInspect();
484  NS_ENSURE_SUCCESS(rv, rv);
485 
486  return NS_OK;
487 }
488 
489 nsresult
490 sbGStreamerService::InspectFactory(GstElementFactory* aFactory,
491  sbIGStreamerInspectHandler* aHandler)
492 {
493  nsresult rv;
494 
495  GstElementFactory* factory;
496  factory =
497  GST_ELEMENT_FACTORY(gst_plugin_feature_load(GST_PLUGIN_FEATURE
498  (aFactory)));
499  NS_ENSURE_TRUE(factory, NS_ERROR_UNEXPECTED);
500 
501  GstElement *element;
502  element = gst_element_factory_create(aFactory, NULL);
503  NS_ENSURE_TRUE(element, NS_ERROR_UNEXPECTED);
504 
505  gint rank = GST_PLUGIN_FEATURE(factory)->rank;
506 
507  rv = aHandler->BeginFactoryInfo(nsDependentCString(GST_PLUGIN_FEATURE(factory)->name),
508  nsDependentCString(factory->details.longname),
509  nsDependentCString(factory->details.klass),
510  nsDependentCString(factory->details.description),
511  nsDependentCString(factory->details.author),
512  nsDependentCString(get_rank_name(rank)),
513  rank);
514  NS_ENSURE_SUCCESS(rv, rv);
515 
516  rv = InspectFactoryPads(element, factory, aHandler);
517  NS_ENSURE_SUCCESS(rv, rv);
518 
519  rv = aHandler->EndFactoryInfo();
520  NS_ENSURE_SUCCESS(rv, rv);
521 
522  return NS_OK;
523 }
524 
525 nsresult
526 sbGStreamerService::InspectFactoryPads(GstElement* aElement,
527  GstElementFactory* aFactory,
528  sbIGStreamerInspectHandler* aHandler)
529 {
530  GstElementClass *gstelement_class;
531  gstelement_class = GST_ELEMENT_CLASS(G_OBJECT_GET_CLASS(aElement));
532  nsresult rv;
533 
534  const GList *pads;
535  pads = aFactory->staticpadtemplates;
536  while (pads) {
537  GstStaticPadTemplate *padtemplate;
538  padtemplate = (GstStaticPadTemplate *) (pads->data);
539  pads = g_list_next(pads);
540 
541  PRUint32 direction;
542  switch (padtemplate->direction) {
543  case GST_PAD_SRC:
545  break;
546  case GST_PAD_SINK:
548  break;
549  default:
551  }
552 
553  PRUint32 presence;
554  switch (padtemplate->presence) {
555  case GST_PAD_ALWAYS:
557  break;
558  case GST_PAD_SOMETIMES:
560  break;
561  default:
563  }
564 
565  nsCString codecDescription;
566 
567  GstCaps* caps = gst_static_caps_get(&padtemplate->static_caps);
568  if (caps) {
569  if (gst_caps_is_fixed(caps)) {
570  gchar* codec = gst_pb_utils_get_codec_description(caps);
571  if (codec) {
572  codecDescription = codec;
573  g_free(codec);
574  }
575  gst_caps_unref(caps);
576  }
577  }
578 
579  if (codecDescription.IsEmpty()) {
580  codecDescription.SetIsVoid(PR_TRUE);
581  }
582  rv = aHandler->BeginPadTemplateInfo(nsDependentCString(padtemplate->name_template),
583  direction,
584  presence,
585  codecDescription);
586  NS_ENSURE_SUCCESS(rv, rv);
587 
588  rv = aHandler->EndPadTemplateInfo();
589  NS_ENSURE_SUCCESS(rv, rv);
590  }
591 
592  return NS_OK;
593 }
594 
595 nsresult
596 sbGStreamerService::UpdateGStreamerRegistryFile()
597 {
598  nsresult rv;
599 
600  // Get the Mozilla component registry file.
601  nsCOMPtr<nsIFile> mozRegFile;
602  rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
603  getter_AddRefs(mozRegFile));
604  NS_ENSURE_SUCCESS(rv, rv);
605  rv = mozRegFile->Append(NS_LITERAL_STRING("compreg.dat"));
606  NS_ENSURE_SUCCESS(rv, rv);
607 
608  // Check if the component registry file exists.
609  PRBool exists;
610  rv = mozRegFile->Exists(&exists);
611  NS_ENSURE_SUCCESS(rv, rv);
612 
613  // Get the last modified time of the component registry file as a string.
614  nsCAutoString lastModifiedTime;
615  if (exists) {
616  PRInt64 lastModifiedTime64;
617  rv = mozRegFile->GetLastModifiedTime(&lastModifiedTime64);
618  NS_ENSURE_SUCCESS(rv, rv);
619  lastModifiedTime.Assign(NS_ConvertUTF16toUTF8
620  (sbAutoString(lastModifiedTime64)));
621  }
622 
623  // Get the last modified time of the component registry file stored in
624  // preferences.
625  nsCAutoString lastModifiedTimePref;
626  nsCOMPtr<nsIPrefBranch>
627  prefBranch = do_GetService("@mozilla.org/preferences-service;1", &rv);
628  NS_ENSURE_SUCCESS(rv, rv);
629  prefBranch->GetCharPref(GSTREAMER_COMPREG_LAST_MODIFIED_TIME_PREF,
630  getter_Copies(lastModifiedTimePref));
631 
632  // If the Mozilla component registry file has been modified since it was last
633  // checked, delete the gstreamer registry file to force it to be regenerated.
634  // This ensures that gstreamer will pick up any new protocol handlers. See
635  // bug 18216.
636  if (lastModifiedTimePref.IsEmpty() ||
637  !lastModifiedTimePref.Equals(lastModifiedTime)) {
638  nsCOMPtr<nsIFile> gstreamerRegFile;
639  rv = GetGStreamerRegistryFile(getter_AddRefs(gstreamerRegFile));
640  NS_ENSURE_SUCCESS(rv, rv);
641  rv = gstreamerRegFile->Exists(&exists);
642  NS_ENSURE_SUCCESS(rv, rv);
643  if (exists) {
644  rv = gstreamerRegFile->Remove(PR_FALSE);
645  NS_ENSURE_SUCCESS(rv, rv);
646  }
647  }
648 
649  // Update the Mozilla component registry file last modified time pref.
650  rv = prefBranch->SetCharPref(GSTREAMER_COMPREG_LAST_MODIFIED_TIME_PREF,
651  lastModifiedTime.get());
652  NS_ENSURE_SUCCESS(rv, rv);
653 
654  return NS_OK;
655 }
656 
657 nsresult
658 sbGStreamerService::GetGStreamerRegistryFile(nsIFile **aOutRegistryFile)
659 {
660  NS_ENSURE_ARG_POINTER(aOutRegistryFile);
661  *aOutRegistryFile = nsnull;
662 
663  nsresult rv;
664  nsCOMPtr<nsIProperties> directorySvc =
665  do_GetService("@mozilla.org/file/directory_service;1", &rv);
666  NS_ENSURE_SUCCESS(rv, rv);
667 
668  nsCOMPtr<nsIFile> registryPath;
669  rv = directorySvc->Get(NS_APP_USER_PROFILE_50_DIR,
670  NS_GET_IID(nsIFile),
671  getter_AddRefs(registryPath));
672  NS_ENSURE_SUCCESS(rv, rv);
673 
674  rv = registryPath->Append(NS_LITERAL_STRING("gstreamer-0.10"));
675  NS_ENSURE_SUCCESS(rv, rv);
676  rv = registryPath->Append(NS_LITERAL_STRING("registry.bin"));
677  NS_ENSURE_SUCCESS(rv, rv);
678 
679  registryPath.forget(aOutRegistryFile);
680  return NS_OK;
681 }
682 
const NS_APP_USER_PROFILE_50_DIR
return NS_OK
void RegisterCustomTags()
onPageChanged aValue
Definition: FeedWriter.js:1395
const unsigned long PAD_PRESENCE_SOMETIMES
static nsresult SB_LoadLibraries(nsIFile *aManifest)
const unsigned long PAD_DIRECTION_SINK
const unsigned long PAD_PRESENCE_REQUEST
const unsigned long PAD_PRESENCE_ALWAYS
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
nsresult SetEnvVar(const nsAString &aName, const nsAString &aValue)
const unsigned long PAD_DIRECTION_SRC
_updateCookies aName
StringArrayEnumerator prototype hasMore
NS_DECL_ISUPPORTS NS_DECL_SBIGSTREAMERSERVICE nsresult Init()
static const char * get_rank_name(gint rank)
#define GSTREAMER_COMPREG_LAST_MODIFIED_TIME_PREF
const unsigned long PAD_DIRECTION_UNKNOWN
return first
#define LOG(args)