void test_load_coreelements() { GstPlugin *unloaded_plugin; GstPlugin *loaded_plugin; //xmlfile = "test_load_coreelements"; std_log(LOG_FILENAME_LINE, "Test Started test_load_coreelements"); unloaded_plugin = gst_default_registry_find_plugin ("coreelements"); fail_if (unloaded_plugin == NULL, "Failed to find coreelements plugin"); fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 2, "Refcount of unloaded plugin in registry initially should be 2"); GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin)); loaded_plugin = gst_plugin_load (unloaded_plugin); fail_if (loaded_plugin == NULL, "Failed to load plugin"); if (loaded_plugin != unloaded_plugin) { fail_if (GST_OBJECT_REFCOUNT_VALUE (loaded_plugin) != 2, "Refcount of loaded plugin in registry should be 2"); GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (loaded_plugin)); fail_if (GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin) != 1, "Refcount of replaced plugin should be 1"); GST_DEBUG ("refcount %d", GST_OBJECT_REFCOUNT_VALUE (unloaded_plugin)); } gst_object_unref (unloaded_plugin); gst_object_unref (loaded_plugin); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_typefind() { GstPlugin *plugin; GstPluginFeature *feature; GstTypeFind typefind = { peek, suggest, NULL, NULL, GST_PADDING_INIT }; //xmlfile = "test_typefind"; std_log(LOG_FILENAME_LINE, "Test Started test_typefind"); plugin = gst_default_registry_find_plugin ("typefindfunctions"); fail_if (plugin == NULL, "Failed to find typefind functions"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in registry should be 2"); /* //commented fail_if (gst_plugin_is_loaded (plugin), "Expected plugin to be unloaded"); */ feature = gst_registry_find_feature (gst_registry_get_default (), "audio/x-au", GST_TYPE_TYPE_FIND_FACTORY); fail_if (feature == NULL, "Failed to find audio/x-aw typefind factory"); #ifndef __SYMBIAN32__ fail_if (feature->plugin != plugin, "Expected identity to be from coreelements plugin"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3, "Refcount of plugin in registry+feature should be 3"); gst_type_find_factory_call_function (GST_TYPE_FIND_FACTORY (feature), &typefind); gst_object_unref (feature->plugin); #endif gst_object_unref (plugin); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 1, "Refcount of plugin in after list free should be 1"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
void test_registry_get_plugin_list() { GList *list; GstPlugin *plugin; //xmlfile = "test_registry_get_plugin_list"; std_log(LOG_FILENAME_LINE, "Test Started test_registry_get_plugin_list"); plugin = gst_default_registry_find_plugin ("coreelements"); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in registry should be 2"); list = gst_registry_get_plugin_list (gst_registry_get_default ()); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 3, "Refcount of plugin in registry+list should be 3"); gst_plugin_list_free (list); fail_if (GST_OBJECT_REFCOUNT_VALUE (plugin) != 2, "Refcount of plugin in after list free should be 2"); gst_object_unref (plugin); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
/*virtual*/ nsresult sbGStreamerMediacoreFactory::OnGetCapabilities( sbIMediacoreCapabilities **aCapabilities) { NS_ENSURE_TRUE(mMonitor, NS_ERROR_NOT_INITIALIZED); nsAutoMonitor mon(mMonitor); // TODO: This function is now a _huge_ mess. We should talk to product about // what files we want to import / etc, some time soon - e.g. the current // approach is to treat anything even vaguely-plausibly audio-related as // audio (even if we can't play it!), but to only import a small list of fixed // extensions for videos (excluding many things we might be able to play). nsresult rv; if (!mCapabilities) { nsRefPtr<sbMediacoreCapabilities> caps; NS_NEWXPCOM(caps, sbMediacoreCapabilities); NS_ENSURE_TRUE(caps, NS_ERROR_OUT_OF_MEMORY); rv = caps->Init(); NS_ENSURE_SUCCESS(rv, rv); // Build a big list of extensions based on everything gstreamer knows about, // plus some known ones, minus a few known non-media-file extensions that // gstreamer has typefinders for. nsCOMPtr<nsIPrefBranch> rootPrefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); nsTArray<nsString> audioExtensions; nsTArray<nsString> videoExtensions; // XXX Mook: we have a silly list of blacklisted extensions because we don't // support them and we're being stupid and guessing things based on them. // This crap should really look for a plugin that may possibly actually decode // these things, or something better. Whatever the real solution is, this // isn't it :( nsCString blacklistExtensions; { // for scope const char defaultBlacklistExtensions[] = "txt,htm,html,xml,pdf,cpl,msstyles,scr,sys,ocx,bz2,gz,zip,Z,rar,tar,dll," "exe,a,bmp,png,gif,jpeg,jpg,jpe,tif,tiff,xpm,dat,swf,swfl,stm,cgi,sf,xcf," "far,wvc,mpc,mpp,mp+,ra,rm,rmvb"; char* blacklistExtensionsPtr = nsnull; rv = rootPrefBranch->GetCharPref(BLACKLIST_EXTENSIONS_PREF, &blacklistExtensionsPtr); if (NS_SUCCEEDED(rv)) { blacklistExtensions.Adopt(blacklistExtensionsPtr); } else { blacklistExtensions.Assign(defaultBlacklistExtensions); } blacklistExtensions.Insert(',', 0); blacklistExtensions.Append(','); LOG(("sbGStreamerMediacoreFactory: blacklisted extensions: %s\n", blacklistExtensions.BeginReading())); } const char *extraAudioExtensions[] = {"m4r", "m4p", "oga", "ogg", "aac", "3gp"}; #ifdef XP_WIN const char *extraWindowsAudioExtensions[] = {"wma" }; #endif { // for scope // Per bug 19550 - // Severly limit the video extensions that are imported by default to: // * ogv (all platforms) // * wmv (windows only) // * mp4/m4v/mov (w/ qtvideowrapper plugin) // * divx/avi/mkv (w/ ewmpeg4dec plugin) videoExtensions.AppendElement(NS_LITERAL_STRING("ogv")); #ifdef XP_WIN videoExtensions.AppendElement(NS_LITERAL_STRING("wmv")); #endif char* knownVideoExtensionsPtr = nsnull; rv = rootPrefBranch->GetCharPref(VIDEO_EXTENSIONS_PREF, &knownVideoExtensionsPtr); if (NS_SUCCEEDED(rv)) { // The override video extension pref contains a CSV string. nsString_Split(NS_ConvertUTF8toUTF16(knownVideoExtensionsPtr), NS_LITERAL_STRING(","), videoExtensions); } #ifdef PR_LOGGING nsString videoExtensionStr; for (PRUint32 i = 0; i < videoExtensions.Length(); i++) { videoExtensionStr.Append(videoExtensions[i]); if (i < videoExtensions.Length() - 1) { videoExtensionStr.AppendLiteral(", "); } } LOG(("sbGStreamerMediacoreFactory: video file extensions: %s\n", videoExtensionStr.get())); #endif // Check for the 'qtvideowrapper' plugin to add mp4/m4v extensions. PRBool foundQTPlugin = PR_FALSE; GstPlugin *plugin = gst_default_registry_find_plugin("qtvideowrapper"); if (plugin) { foundQTPlugin = PR_TRUE; videoExtensions.AppendElement(NS_LITERAL_STRING("mp4")); videoExtensions.AppendElement(NS_LITERAL_STRING("m4v")); videoExtensions.AppendElement(NS_LITERAL_STRING("mov")); gst_object_unref(plugin); } // Check for the 'ewmpeg4dec' plugin to add divx/avi extensions. plugin = gst_default_registry_find_plugin("ewmpeg4dec"); if (plugin) { videoExtensions.AppendElement(NS_LITERAL_STRING("divx")); videoExtensions.AppendElement(NS_LITERAL_STRING("avi")); videoExtensions.AppendElement(NS_LITERAL_STRING("mkv")); // This plugin will also handle "mp4" and "m4v", only append those // extensions if they haven't been added already. if (!foundQTPlugin) { videoExtensions.AppendElement(NS_LITERAL_STRING("mp4")); videoExtensions.AppendElement(NS_LITERAL_STRING("m4v")); } gst_object_unref(plugin); } } GList *walker, *list; list = gst_type_find_factory_get_list (); walker = list; while (walker) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walker->data); gboolean blacklisted = FALSE; const gchar* factoryName = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)); gboolean isAudioFactory = g_str_has_prefix(factoryName, "audio/"); gchar **factoryexts = gst_type_find_factory_get_extensions (factory); if (factoryexts) { while (*factoryexts) { gboolean isAudioExtension = isAudioFactory; nsCString extension(*factoryexts); nsCString delimitedExtension(extension); delimitedExtension.Insert(',', 0); delimitedExtension.Append(','); blacklisted = (blacklistExtensions.Find(delimitedExtension) != -1); #if PR_LOGGING if (blacklisted) { LOG(("sbGStreamerMediacoreFactory: Ignoring extension '%s'", *factoryexts)); } #endif /* PR_LOGGING */ if (!blacklisted && isAudioExtension) { audioExtensions.AppendElement(NS_ConvertUTF8toUTF16(*factoryexts)); LOG(("sbGStreamerMediacoreFactory: registering audio extension %s\n", *factoryexts)); } factoryexts++; } } walker = g_list_next (walker); } g_list_free (list); for (unsigned int i = 0; i < NS_ARRAY_LENGTH(extraAudioExtensions); i++) { nsString ext = NS_ConvertUTF8toUTF16(extraAudioExtensions[i]); if(!audioExtensions.Contains(ext)) audioExtensions.AppendElement(ext); } #if XP_WIN for (unsigned int i = 0; i < NS_ARRAY_LENGTH(extraWindowsAudioExtensions); i++) { nsString ext = NS_ConvertUTF8toUTF16(extraWindowsAudioExtensions[i]); if(!audioExtensions.Contains(ext)) audioExtensions.AppendElement(ext); } #endif rv = caps->SetAudioExtensions(audioExtensions); NS_ENSURE_SUCCESS(rv, rv); // Audio playback is always allowed. rv = caps->SetSupportsAudioPlayback(PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); PRBool videoDisabled = PR_FALSE; rv = rootPrefBranch->GetBoolPref( "songbird.mediacore.gstreamer.disablevideo", &videoDisabled); NS_ENSURE_SUCCESS(rv, rv); if (!videoDisabled) { rv = caps->SetVideoExtensions(videoExtensions); NS_ENSURE_SUCCESS(rv, rv); rv = caps->SetSupportsVideoPlayback(PR_TRUE); NS_ENSURE_SUCCESS(rv, rv); } mCapabilities = caps; } rv = CallQueryInterface(mCapabilities.get(), aCapabilities); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
int main (int argc, char *argv[]) { gboolean print_all = FALSE; gboolean print_aii = FALSE; GOptionEntry options[] = { {"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all, N_("Print all elements"), NULL}, {"print-plugin-auto-install-info", '\0', 0, G_OPTION_ARG_NONE, &print_aii, N_("Print a machine-parsable list of features the specified plugin " "provides.\n " "Useful in connection with external automatic plugin " "installation mechanisms"), NULL}, GST_TOOLS_GOPTION_VERSION, {NULL} }; GOptionContext *ctx; GError *err = NULL; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!g_thread_supported ()) g_thread_init (NULL); ctx = g_option_context_new ("[ELEMENT-NAME | PLUGIN-NAME]"); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", err->message); exit (1); } g_option_context_free (ctx); gst_tools_print_version ("gst-inspect"); if (print_all && argc > 2) { g_print ("-a requires no extra arguments\n"); return 1; } /* if no arguments, print out list of elements */ if (argc == 1 || print_all) { print_element_list (print_all); /* else we try to get a factory */ } else { GstElementFactory *factory; GstPlugin *plugin; const char *arg = argv[argc - 1]; int retval; factory = gst_element_factory_find (arg); /* if there's a factory, print out the info */ if (factory) { retval = print_element_info (factory, print_all); gst_object_unref (factory); } else { retval = print_element_features (arg); } /* otherwise check if it's a plugin */ if (retval) { plugin = gst_default_registry_find_plugin (arg); /* if there is such a plugin, print out info */ if (plugin) { if (print_aii) { print_plugin_automatic_install_info (plugin); } else { print_plugin_info (plugin); print_plugin_features (plugin); } } else { GError *error = NULL; if (g_file_test (arg, G_FILE_TEST_EXISTS)) { plugin = gst_plugin_load_file (arg, &error); if (plugin) { if (print_aii) { print_plugin_automatic_install_info (plugin); } else { print_plugin_info (plugin); print_plugin_features (plugin); } } else { g_print (_("Could not load plugin file: %s\n"), error->message); g_error_free (error); return -1; } } else { g_print (_("No such element or plugin '%s'\n"), arg); return -1; } } } } return 0; }