예제 #1
0
파일: main.cpp 프로젝트: KDE/libqapt
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    app.setWindowIcon(QIcon::fromTheme("applications-other"));

    KLocalizedString::setApplicationDomain("qapt-gst-helper");

    KAboutData aboutData("qapt-gst-helper",
                         i18nc("@title", "QApt Codec Searcher"),
                         version,
                         i18nc("@info", description),
                         KAboutLicense::LicenseKey::GPL,
                         i18nc("@info:credit", "(C) 2011 Jonathan Thomas"));

    aboutData.addAuthor(i18nc("@info:credit", "Jonathan Thomas"),
                        QString(),
                        QStringLiteral("*****@*****.**"));
    aboutData.addAuthor(i18nc("@info:credit", "Harald Sitter"),
                        i18nc("@info:credit", "Qt 5 port"),
                        QStringLiteral("*****@*****.**"));
    KAboutData::setApplicationData(aboutData);

    QCommandLineParser parser;
    parser.addHelpOption();
    parser.addVersionOption();
    QCommandLineOption transientOption(QStringLiteral("transient-for"),
                                       i18nc("@info:shell", "Attaches the window to an X app specified by winid"),
                                       i18nc("@info:shell value name", "winid"),
                                       QStringLiteral("0"));
    parser.addOption(transientOption);
    parser.addPositionalArgument("GStreamer Info",
                                 i18nc("@info:shell", "GStreamer install info"));
    aboutData.setupCommandLine(&parser);
    parser.process(app);
    aboutData.processCommandLine(&parser);

    GError *error = nullptr;
    gst_init_check(&argc, &argv, &error);
    if (error) {
        // TODO: we should probably show an error message. API documention suggests
        // so at least. Then again explaining random init errors to the user
        // might be a bit tricky.
#warning FIXME 3.1 show error msgbox when gstreamer init fails
        return GST_INSTALL_PLUGINS_ERROR;
    }

    // do not restore!
    if (app.isSessionRestored()) {
        exit(0);
    }

    int winId = parser.value(transientOption).toInt();
    QStringList details = parser.positionalArguments();

    PluginHelper pluginHelper(0, details, winId);
    pluginHelper.run();

    return app.exec();
}
예제 #2
0
파일: player.cpp 프로젝트: shil99/study
GstDriver::GstDriver(MediaPlayerHWInterface* parent):
{
    init_gstreamer();
    {
        // set debug
        property_get("persist.gst.debug", debug, "0");
      	gst_debug_remove_log_function(debug_log);
    	gst_debug_add_log_function(debug_log, this);
	    gst_debug_remove_log_function(gst_debug_log_default);

        gst_init_check (&argc, &argv, &err);
    }
예제 #3
0
gboolean streamer_init() {
	GError* e;
	gboolean res;

	res = gst_init_check(NULL, NULL, &e);
	if (!res) {
		g_printerr("%s", e->message);
	}

	g_mutex_init(&app.mutex);
	return res;
}
예제 #4
0
파일: Player.cpp 프로젝트: abresee/note
Player::Backend::Backend(Player * player):
    pipeline_(),
    appsrc_(),
    conv_(),
    audiosink_(),
    loop_(),
    push_id_(),
    bus_watch_id_(),
    player_(player) {
    if(!gst_is_initialized()) {
        GError *err;
        if(!gst_init_check(nullptr,nullptr,&err)) {
            std::exit(err->code);
        }
    }

    pipeline_ = gst_pipeline_new ("pipeline");

    if(pipeline_==nullptr) {
        std::exit(EXIT_FAILURE);
    };

    build_gst_element(appsrc_,"appsrc","source");
    build_gst_element(conv_,"audioconvert","conv");

    GstBus * bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline_));
    bus_watch_id_ = gst_bus_add_watch (bus, wrap_bus_callback, this);
    gst_object_unref (bus);
    
    GstCaps * caps = gst_caps_new_simple(
        "audio/x-raw",
        "format", G_TYPE_STRING, format_,
        "rate", G_TYPE_INT, Config::sample_rate,
        "channels",G_TYPE_INT, Config::channels,
        "signed", G_TYPE_BOOLEAN, TRUE,
        "layout", G_TYPE_STRING, "interleaved",
        nullptr);

    g_object_set(G_OBJECT(appsrc_),"caps",caps,nullptr);
    g_object_set(G_OBJECT(appsrc_),"is-live",true,nullptr);
    g_object_set(G_OBJECT(appsrc_),"min-latency",0,nullptr);
    g_object_set(G_OBJECT(appsrc_),"emit-signals",false,nullptr);
    g_object_set(G_OBJECT(appsrc_),"format",GST_FORMAT_TIME,nullptr);

    //the gstreamer main loop is the main event loop for audio generation
    loop_ = g_main_loop_new (nullptr, FALSE);

    gst_bin_add_many (GST_BIN (pipeline_), appsrc_, conv_, nullptr);
    gst_element_link (appsrc_, conv_);

    GstAppSrcCallbacks callbacks = {wrap_need_data, wrap_enough_data, wrap_seek_data};
    gst_app_src_set_callbacks(GST_APP_SRC(appsrc_), &callbacks, this, nullptr);
}
예제 #5
0
/* Init the video interface. Start GStreamer and create all the elements. */
int video_init(int flags)
{
	GstElement *dec, *vqueue, *vconv, *vscale, *aqueue, *aconv, *ascale;

	if (!gst_init_check(NULL, NULL)) return VIDEO_ERROR;

	status = 0;
	status_mutex = g_mutex_new();
	video_width = video_height = 0;
	apeer = NULL;
	audio_disabled = flags & VIDEO_INIT_NOAUDIO;

	/* Main pipeline */
	pipeline = gst_thread_new("pipeline");
	g_signal_connect(pipeline, "eos", G_CALLBACK (cb_eos), NULL);
	g_signal_connect(pipeline, "error", G_CALLBACK (cb_error), NULL);
	g_signal_connect(pipeline, "state-change", G_CALLBACK (cb_state_change), NULL);
	src = gst_element_factory_make("filesrc", "src");
	dec = gst_element_factory_make("decodebin", "dec");
	g_signal_connect (dec, "new-decoded-pad", G_CALLBACK(cb_new_pad), NULL);
	if (!gst_element_link_many(src, dec, NULL)) return VIDEO_ERROR;
	gst_bin_add_many(GST_BIN(pipeline), src, dec, NULL);

	/* Video thread */
	vthread = gst_thread_new("vthread");
	vqueue = gst_element_factory_make("queue", "vqueue");
	vqueuesink = gst_element_get_pad(vqueue, "sink");
	vconv = gst_element_factory_make("ffmpegcolorspace", "vconv");
	vscale = gst_element_factory_make("videoscale", "vscale");
	vdrop = gst_element_factory_make("videodrop", "vdrop");
	xvsink = gst_element_factory_make("xvimagesink", "xvsink");
	gst_bin_add_many(GST_BIN(vthread), vqueue, vconv, vscale, vdrop, xvsink, NULL);
	if (!gst_element_link_many(vqueue, vconv, vscale, vdrop, xvsink, NULL)) 
		return VIDEO_ERROR;
	gst_object_ref(GST_OBJECT(vthread));

	/* Audio thread */
	if (audio_disabled) return VIDEO_OK;

	athread = gst_thread_new("athread");
	aqueue = gst_element_factory_make("queue", "aqueue");
	aqueuesink = gst_element_get_pad(aqueue, "sink");
	aconv = gst_element_factory_make("audioconvert", "aconv");
	ascale = gst_element_factory_make ("audioscale", "ascale");
	asink = gst_element_factory_make ("alsasink", "asink");
	gst_bin_add_many (GST_BIN (athread), aqueue, aconv, ascale, asink, NULL);
	if (!gst_element_link_many (aqueue, aconv, ascale, asink, NULL))
		return VIDEO_ERROR;
	gst_object_ref(GST_OBJECT(athread));

	return VIDEO_OK;
}
bool initializeGStreamer()
{
#if GST_CHECK_VERSION(0, 10, 31)
    if (gst_is_initialized())
        return true;
#endif

    GOwnPtr<GError> error;
    // FIXME: We should probably pass the arguments from the command line.
    bool gstInitialized = gst_init_check(0, 0, &error.outPtr());
    ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");
    return gstInitialized;
}
예제 #7
0
void GStreamerCore::_Init()
{

	GError *err = 0;
	_gst_debug_enabled = false; 
	if (!gst_init_check(0,0, &err))
	{
		LogManager::Instance()->LogMessage("GStreamerCore - Failed to init GStreamer!");
	}
	else
	{
		g_log_set_handler(0,  G_LOG_LEVEL_CRITICAL, g_logFunction, 0);
		g_log_set_handler(0, G_LOG_FLAG_FATAL , g_logFunction, 0);
		g_log_set_default_handler(g_logFunction, 0);

		fclose(stderr);

		//register plugin path
		std::string gst_path = g_getenv("GSTREAMER_1_0_ROOT_X86_64");
		//putenv(("GST_PLUGIN_PATH_1_0=" + gst_path + "lib\\gstreamer-1.0" + ";.").c_str());
		//add our custom src/sink elements
		gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
			"appsink", (char*)"Element application sink",
			appsink_plugin_init, "0.1", "LGPL", "ofVideoPlayer", "openFrameworks",
			"http://openframeworks.cc/");
		gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
			"mysrc", (char*)"Element application src",
			_GstMySrcClass::plugin_init, "0.1", "LGPL", "GstVideoProvider", "mray",
			"");
		gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
			"mysink", (char*)"Element application sink",
			_GstMySinkClass::plugin_init, "0.1", "LGPL", "GstVideoProvider", "mray",
			"");
		gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
			"myudpsrc", (char*)"Element udp src",
			_GstMyUDPSrcClass::plugin_init, "0.1", "LGPL", "GstVideoProvider", "mray",
			"");
		gst_plugin_register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR,
			"myudpsink", (char*)"Element udp sink",
			_GstMyUDPSinkClass::plugin_init, "0.1", "LGPL", "GstVideoProvider", "mray",
			"");
		LogMessage("GStreamerCore - GStreamer inited", ELL_INFO);
	}

#if GLIB_MINOR_VERSION<32
	if (!g_thread_supported()){
		g_thread_init(NULL);
	}
#endif
	_StartLoop();
}
예제 #8
0
/**
 * gst_init:
 * @argc: (inout) (allow-none): pointer to application's argc
 * @argv: (inout) (array length=argc) (allow-none): pointer to application's argv
 *
 * Initializes the GStreamer library, setting up internal path lists,
 * registering built-in elements, and loading standard plugins.
 *
 * Unless the plugin registry is disabled at compile time, the registry will be
 * loaded. By default this will also check if the registry cache needs to be
 * updated and rescan all plugins if needed. See gst_update_registry() for
 * details and section
 * <link linkend="gst-running">Running GStreamer Applications</link>
 * for how to disable automatic registry updates.
 *
 * <note><para>
 * This function will terminate your program if it was unable to initialize
 * GStreamer for some reason.  If you want your program to fall back,
 * use gst_init_check() instead.
 * </para></note>
 *
 * WARNING: This function does not work in the same way as corresponding
 * functions in other glib-style libraries, such as gtk_init\(\). In
 * particular, unknown command line options cause this function to
 * abort program execution.
 */
void
gst_init (int *argc, char **argv[])
{
  GError *err = NULL;

  if (!gst_init_check (argc, argv, &err)) {
    g_print ("Could not initialize GStreamer: %s\n",
        err ? err->message : "unknown error occurred");
    if (err) {
      g_error_free (err);
    }
    exit (1);
  }
}
예제 #9
0
//
// STARTUP
///////////////////////////////////////////////////////////////////////////////
// (static) super-initialization - called once at application startup
bool LLMediaImplGStreamer::startup (LLMediaManagerData* init_data)
{
	static bool done_init = false;
	if (!done_init)
	{
		// Init the glib type system - we need it.
		g_type_init();

		set_gst_plugin_path();

		// Protect against GStreamer resetting the locale, yuck.
		static std::string saved_locale;
		saved_locale = setlocale(LC_ALL, NULL);
		if (0 == gst_init_check(NULL, NULL, NULL))
		{
		    LL_WARNS("MediaImpl") << "GStreamer library failed to initialize and load standard plugins." << LL_ENDL;
			setlocale(LC_ALL, saved_locale.c_str() );
			return false;
		}
		setlocale(LC_ALL, saved_locale.c_str() );

		// Set up logging facilities
		gst_debug_remove_log_function( gst_debug_log_default );
		gst_debug_add_log_function( gstreamer_log, NULL );

		// Init our custom plugins - only really need do this once.
		gst_slvideo_init_class();


		// List the plugins GStreamer can find
		LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
		GList *list;
		GstRegistry *registry = gst_registry_get_default();
		std::string loaded = "";
		for (list = gst_registry_get_plugin_list(registry);
		     list != NULL;
		     list = g_list_next(list))
		{	 
			GstPlugin *list_plugin = (GstPlugin *)list->data;
			(bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
			LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
		}
		gst_plugin_list_free(list);


		done_init = true;
	}
	return true;
}
예제 #10
0
static gboolean gstvideo_init(void)
{
    static int success = 0;
    if (!success) {
        GError *err = NULL;
        if (gst_init_check(NULL, NULL, &err)) {
            success = 1;
        } else {
            spice_warning("Disabling GStreamer video support: %s", err->message);
            g_clear_error(&err);
            success = -1;
        }
    }
    return success > 0;
}
예제 #11
0
gboolean
gstreamer_init (void)
{
	if (! gstreamer_initialized) {
		GError *error = NULL;

		if (! gst_init_check (NULL, NULL, &error)) {
			g_warning ("%s", error->message);
			g_error_free (error);
			return FALSE;
		}

		gstreamer_initialized = TRUE;
	}

	return TRUE;
}
예제 #12
0
    void ConnectionProvider::InitializeGStreamer()
    {
        std::string fs_plugin_path = Poco::Path::current();
        fs_plugin_path.append("gstreamer\\lib\\farsight2-0.0");
        Poco::Environment::set("FS_PLUGIN_PATH", fs_plugin_path);        

        QString gst_plugin_path = QString(Poco::Path::current().c_str()).append("gstreamer\\lib\\gstreamer-0.10");
        Poco::Environment::set("GST_PLUGIN_PATH", gst_plugin_path.toStdString().c_str());        

        const int ARGC = 5;
        QString arg_gst_plugin_path(QString("--gst-plugin-path=").append(gst_plugin_path).append(""));
        QString arg_gst_disable_registry_update("--gst-disable-registry-update");
        QString arg_gst_disable_registry_fork("--gst-disable-registry-fork");

        int argc = ARGC;
        char* argv[ARGC];
        std::string args[ARGC];
        args[0] = ""; // first argument will be ignored
        args[1] = arg_gst_plugin_path.toStdString();
        args[2] = ""; //arg_gst_disable_registry_update.toStdString();
        args[3] = arg_gst_disable_registry_fork.toStdString();
        args[4] = ""; // "--gst-debug-level=3"; //arg_gst_disable_registry_fork.toStdString();
        for (int i=0; i < ARGC; ++i)
        {
            argv[i] = (char*)args[i].c_str();
            QString message = QString("gstreamer init arg: ").append(QString(args[i].c_str()));
            LogDebug(message.toStdString());
        }
        char** p_argv = &argv[0];
        GError error;
        GError *p_error = &error;
        if (!gst_init_check(&argc, &p_argv, &p_error))
        {
            QString error_message("Cannot initialize GStreamer: ");
            error_message.append(p_error->message);
            LogError(error_message.toStdString());
            return;
        }
        guint major, minor, micro, nano;
        gst_version (&major, &minor, &micro, &nano);
        QString text;
        text.sprintf("GStreamer version %i.%i.%i.%i initialized.", major, minor, micro, nano);
        LogInfo(text.toStdString());
    }
예제 #13
0
// ----------------------------------------------------------------------------
// Instantiate GStreamerImportPlugin and add to the list of known importers
void
GetGStreamerImportPlugin(ImportPluginList *importPluginList,
                         UnusableImportPluginList * WXUNUSED(unusableImportPluginList))
{
   wxLogMessage(wxT("Audacity is built against GStreamer version %d.%d.%d-%d"),
                GST_VERSION_MAJOR,
                GST_VERSION_MINOR,
                GST_VERSION_MICRO,
                GST_VERSION_NANO);

   // Initializa gstreamer
   GError *error;
   int argc = 0;
   char **argv = NULL;
   if (!gst_init_check(&argc, &argv, &error))
   {
      wxLogMessage(wxT("Failed to initialize GStreamer. Error %d: %s"),
                   error->code,
                   wxString::FromUTF8(error->message).c_str());
      g_error_free(error);
      return;
   }

   guint major, minor, micro, nano;
   gst_version(&major, &minor, &micro, &nano);
   wxLogMessage(wxT("Linked to GStreamer version %d.%d.%d-%d"),
                major,
                minor,
                micro,
                nano);

   // Instantiate plugin
   GStreamerImportPlugin *plug = new GStreamerImportPlugin();

   // No supported extensions...no gstreamer plugins installed
   if (plug->GetSupportedExtensions().GetCount() == 0)
   {
      delete plug;
      return;
   }

   // Add to list of importers
   importPluginList->Append(plug);
}
예제 #14
0
파일: tgstengine.cpp 프로젝트: KDE/tupi
bool TGstEngine::init()
{
    GError *err;
    if (!gst_init_check(NULL, NULL, &err)) {
        qDebug() << "Error gst_init_check";
        return false;
    }

    // Check if registry exists
    GstElement* dummy = gst_element_factory_make ( "fakesink", "fakesink" );
    if (!dummy) {
        qDebug() << "gst-register";
        return false;
    }

    gst_object_unref(dummy);

    return true;
}
예제 #15
0
EXPORT_API void gub_ref(const char *gst_debug_string)
{
    gub_log("GST ref (%d -> %d)", gub_ref_count, gub_ref_count + 1);
    if (gub_ref_count == 0) {
        GError *err = 0;
        gchar *version = NULL;

        if (!gst_init_check(0, 0, &err)) {
            gub_log("Failed to initialize GStreamer: %s", err ? err->message : "<No error message>");
            return;
        }

        /* get time we started for debugging messages */
        _priv_gst_info_start_time = gst_util_get_timestamp();

        gst_debug_remove_log_function(gst_debug_log_default);
        gst_debug_add_log_function((GstLogFunction)gst_debug_gub, NULL, NULL);
        if (gst_debug_string) {
            gub_log("Setting debug level to %s", gst_debug_string);
            gst_debug_set_active(TRUE);
            gst_debug_set_threshold_from_string(gst_debug_string, TRUE);
        } else {
            gst_debug_set_active(FALSE);
        }

#if defined (__ANDROID__)
        gst_android_register_static_plugins();
        gst_android_load_gio_modules();
#endif

        gub_main_loop_thread = g_thread_new("GstUnityBridge Main Thread", gub_main_loop_func, NULL);
        if (!gub_main_loop_thread) {
            gub_log("Failed to create GLib main thread: %s", err ? err->message : "<No error message>");
            return;
        }

        version = gst_version_string();
        gub_log("%s initialized", version);
        g_free(version);
    }

    gub_ref_count++;
}
예제 #16
0
파일: media.cpp 프로젝트: jasuarez/minbif
void Media::init()
{
#ifdef HAVE_VIDEO
	GError *error = NULL;
	if((gstreamer_init_failed = !gst_init_check(NULL, NULL, &error)))
	{
		b_log[W_ERR] << "Unable to initialize GStreamer: " << (error ? error->message : "");
		if(error)
			g_free(error);
		return;
	}

	PurpleMediaManager *manager = purple_media_manager_get();
	PurpleMediaElementInfo *default_video_src =
			(PurpleMediaElementInfo*)g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
			"id", "minbifdefaultvideosrc",
			"name", "minbif Default Video Source",
			"type", PURPLE_MEDIA_ELEMENT_VIDEO
					| PURPLE_MEDIA_ELEMENT_SRC
					| PURPLE_MEDIA_ELEMENT_ONE_SRC
					| PURPLE_MEDIA_ELEMENT_UNIQUE,
			"create-cb", create_default_video_src, NULL);
	PurpleMediaElementInfo *default_video_sink =
			(PurpleMediaElementInfo*)g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
			"id", "minbifdefaultvideosink",
			"name", "minbif Default Video Sink",
			"type", PURPLE_MEDIA_ELEMENT_VIDEO
					| PURPLE_MEDIA_ELEMENT_SINK
					| PURPLE_MEDIA_ELEMENT_ONE_SINK,
			"create-cb", create_default_video_sink, NULL);

	g_signal_connect(G_OBJECT(manager), "init-media",
			 G_CALLBACK(media_new_cb), NULL);

	purple_media_manager_set_ui_caps(manager, (PurpleMediaCaps)(
			PURPLE_MEDIA_CAPS_VIDEO |
			PURPLE_MEDIA_CAPS_VIDEO_SINGLE_DIRECTION));

	purple_media_manager_set_active_element(manager, default_video_sink);
	purple_media_manager_set_active_element(manager, default_video_src);

#endif /* HAVE_VIDEO */
}
예제 #17
0
int
main (int argc, char *argv[])
{
  gboolean res;
  char **my_argv;
  int my_argc;

  if (argc != 2 || strcmp (argv[1], "-l"))
    return 1;

#if !GLIB_CHECK_VERSION (2, 31, 0)
  if (!g_thread_supported ())
    g_thread_init (NULL);
#endif

  my_argc = 2;
  my_argv = g_malloc (my_argc * sizeof (char *));
  my_argv[0] = argv[0];
  my_argv[1] = (char *) "--gst-disable-registry-update";

#ifndef GST_DISABLE_REGISTRY
  _gst_disable_registry_cache = TRUE;
#endif

  res = gst_init_check (&my_argc, &my_argv, NULL);

  g_free (my_argv);
  if (!res)
    return 1;

  /* Create registry scanner listener and run */
  if (!_gst_plugin_loader_client_run ())
    return 1;

  return 0;
}
bool VideoPlayerBackend::initGStreamer(QString *errorMessage)
{
    static bool loaded = false;
    if (loaded)
        return true;

    GError *err;
    if (gst_init_check(0, 0, &err) == FALSE)
    {
        Q_ASSERT(err);
        qWarning() << "GStreamer initialization failed:" << err->message;
        if (errorMessage)
            *errorMessage = QString::fromLatin1("initialization failed: ") + QString::fromLatin1(err->message);
        g_error_free(err);
        return false;
    }

#ifdef Q_OS_LINUX
    if (QString::fromLatin1(GSTREAMER_PLUGINS).isEmpty())
        return true;
#endif

#ifdef Q_OS_WIN
#define EXT ".dll"
#else
#define EXT ".so"
#endif

    const char *plugins[] =
    {
        "libgsttypefindfunctions"EXT, "libgstapp"EXT, "libgstdecodebin2"EXT, "libgstmatroska"EXT,
        "libgstffmpegcolorspace"EXT, "libgstcoreelements"EXT,
#ifndef Q_OS_WIN
        "libgstffmpeg"EXT,
#endif
#ifdef Q_OS_WIN
        "libgstffmpeg-lgpl"EXT, "libgstautodetect"EXT,
#elif defined(Q_OS_MAC)
        "libgstosxaudio"EXT,
#endif
        0
    };

#undef EXT
#if defined(Q_OS_MAC)
    QString pluginPath = QApplication::applicationDirPath() + QLatin1String("/../PlugIns/gstreamer/");
#else
    QString pluginPath = QDir::toNativeSeparators(QApplication::applicationDirPath() + QDir::separator());
#endif

#if defined(GSTREAMER_PLUGINS) and not defined(Q_OS_MAC)
    QString ppx = QDir::toNativeSeparators(QString::fromLatin1(GSTREAMER_PLUGINS "/"));
    if (QDir::isAbsolutePath(ppx))
        pluginPath = ppx;
    else
        pluginPath += ppx;
#endif

    if (!QFile::exists(pluginPath))
    {
        qWarning() << "gstreamer: Plugin path" << pluginPath << "does not exist";
        if (errorMessage)
            *errorMessage = QString::fromLatin1("plugin path (%1) does not exist").arg(pluginPath);
        return false;
    }

    bool success = true;
    QByteArray path = QFile::encodeName(pluginPath);
    int pathEnd = path.size();

    if (errorMessage)
        errorMessage->clear();

    for (const char **p = plugins; *p; ++p)
    {
        path.truncate(pathEnd);
        path.append(*p);

        GError *err = 0;
        GstPlugin *plugin = gst_plugin_load_file(path.constData(), &err);
        if (!plugin)
        {
            Q_ASSERT(err);
            qWarning() << "gstreamer: Failed to load plugin" << *p << ":" << err->message;
            if (errorMessage)
                errorMessage->append(QString::fromLatin1("plugin '%1' failed: %2\n").arg(QLatin1String(*p))
                                     .arg(QLatin1String(err->message)));
            g_error_free(err);
            success = false;
        }
        else
        {
            Q_ASSERT(!err);
            gst_object_unref(plugin);
        }
    }

    if (success)
        loaded = true;
    return success;
}
bool VideoReceiver::enableVideo(bool enable)
{
  GstElement *rtpdepay, *decoder, *sink;
  GstBus *bus;
  GstCaps *caps;

  if (!enable) {
	qCritical("disabling VideoReceiver not implemented");
	return false;
  }


  // Initialisation. We don't pass command line arguments here
  if (!gst_init_check(NULL, NULL, NULL)) {
	qCritical("Failed to init GST");
	return false;
  }

  // Create receiving video pipeline 

  pipeline = gst_pipeline_new("videopipeline");

  source        = gst_element_factory_make("appsrc", "source");
  rtpdepay      = gst_element_factory_make("rtph263depay", "rtpdepay");
  decoder       = gst_element_factory_make("ffdec_h263", "decoder");
  sink          = gst_element_factory_make("xvimagesink", "sink");

  g_object_set(G_OBJECT(sink), "sync", false, NULL);
  g_object_set(G_OBJECT(source), "do-timestamp", true, NULL);
  // Set the stream to act "live stream"
  g_object_set(G_OBJECT(source), "is-live", true, NULL);
  // Set the stream type to "stream"
  g_object_set(G_OBJECT(source), "stream-type", 0, NULL);

  // Set the caps for appsrc
  caps = gst_caps_new_simple("application/x-rtp",
							 "media", G_TYPE_STRING, "video",
							 "clock-rate", G_TYPE_INT, 90000,
							 "encoding-name", G_TYPE_STRING, "H263",
							 "payload", G_TYPE_INT, 96,
							 "framerate", GST_TYPE_FRACTION, 10, 1,
							 NULL);
  gst_app_src_set_caps(GST_APP_SRC(source), caps);
  gst_caps_unref (caps);

  gst_bin_add_many(GST_BIN(pipeline), 
				   source, rtpdepay, decoder, sink, NULL);

  // Link 
  if (!gst_element_link_many(source, rtpdepay, decoder, sink, NULL)) {
    qCritical("Failed to link elements!");
	return false;
  }

  // Add a watch for new messages on our pipeline's message bus
  bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
  gst_bus_add_watch(bus, busCall, this);
  gst_object_unref(bus);
  bus = NULL;

  // Start running 
  gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);

  return true;
}
예제 #20
0
파일: UgApp-gtk-main.c 프로젝트: Endz0/uget
// ----------------------------------------------------------------------------
int main (int argc, char** argv)
{
	gchar*		string;
	gint		ipc_status;

	// I18N
#ifdef LOCALEDIR
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#else
	string = g_build_filename (ug_get_data_dir (), "locale", NULL);
	bindtextdomain (GETTEXT_PACKAGE, string);
	g_free (string);
#endif
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

#ifdef USE_GNUTLS
	init_locks ();
#endif

	string = ug_arg_find_version (argc, argv);
	if (string) {
#if defined (_WIN32) && defined (_WINDOWS)
		win32_console_init ();
#endif  // _WIN32 && _WINDOWS
		g_print ("uGet " PACKAGE_VERSION " for GTK+" "\n");
		return EXIT_SUCCESS;
	}
	string = ug_arg_find_help (argc, argv);
	// initialize for MS-Windows
#if defined (_WIN32)
#if defined (_WINDOWS)
	if (string)
		win32_console_init ();
#endif  // _WINDOWS
	win32_winsock_init ();
#endif  // _WIN32

	// uglib: options
	app = g_slice_alloc0 (sizeof (UgAppGtk));
	ug_option_init (&app->option);
	ug_option_add (&app->option, NULL, gtk_get_option_group (TRUE));
	if (string) {
		g_print ("uGet " PACKAGE_VERSION " for GTK+" "\n");
		ug_option_help (&app->option, argv[0], string);
	}

	// GTK+
	gtk_init (&argc, &argv);

	// GStreamer
#ifdef HAVE_GSTREAMER
	gst_inited = gst_init_check (&argc, &argv, NULL);
#endif

	// IPC initialize & check exist Uget program
	ipc_status = ug_ipc_init_with_args (&app->ipc, argc, argv);
	if (ipc_status < 1) {
		if (ipc_status == -1)
			g_print ("uget: IPC failed.\n");
//		if (ipc_status == 0)
//			g_print ("uget: Server exists.\n");
		ug_ipc_finalize (&app->ipc);
		goto exit;
	}
	// libnotify
#ifdef HAVE_LIBNOTIFY
	notify_init ("uGet");
#endif

	// register uget interfaces
	uglib_init ();

	// main program
	ug_app_init (app);
	signal (SIGTERM, term_signal_handler);
	gtk_main ();

	// libnotify
#ifdef HAVE_LIBNOTIFY
	if (notify_is_initted ())
		notify_uninit ();
#endif
	// shutdown IPC and sleep 3 second to wait thread
	g_usleep (3 * 1000000);
	ug_ipc_finalize (&app->ipc);

exit:
	// finalize for MS-Windows
#ifdef _WIN32
	win32_winsock_finalize ();
#endif

	return EXIT_SUCCESS;
}
예제 #21
0
static void
pidgin_sound_init(void)
{
	void *gtk_sound_handle = pidgin_sound_get_handle();
	void *blist_handle = purple_blist_get_handle();
	void *conv_handle = purple_conversations_get_handle();
#ifdef USE_GSTREAMER
	GError *error = NULL;
#endif

	purple_signal_connect(purple_connections_get_handle(), "signed-on",
						gtk_sound_handle, PURPLE_CALLBACK(account_signon_cb),
						NULL);

	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound");
	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/enabled");
	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/sound/file");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/login", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/login", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/logout", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/logout", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/im_recv", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/im_recv", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/first_im_recv", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/first_im_recv", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_im", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_im", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/join_chat", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/join_chat", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/left_chat", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/left_chat", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/send_chat_msg", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/send_chat_msg", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/chat_msg_recv", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/chat_msg_recv", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/nick_said", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/nick_said", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/pounce_default", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/pounce_default", "");
	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/theme", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/sent_attention", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/sent_attention", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/enabled/got_attention", TRUE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/file/got_attention", "");
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/conv_focus", TRUE);
	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
	purple_prefs_add_path(PIDGIN_PREFS_ROOT "/sound/command", "");
	purple_prefs_add_string(PIDGIN_PREFS_ROOT "/sound/method", "automatic");
	purple_prefs_add_int(PIDGIN_PREFS_ROOT "/sound/volume", 50);

#ifdef USE_GSTREAMER
	purple_debug_info("sound", "Initializing sound output drivers.\n");
	gst_registry_fork_set_enabled(FALSE);
	if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
		purple_notify_error(NULL, _("GStreamer Failure"),
					_("GStreamer failed to initialize."),
					error ? error->message : "", NULL);
		if (error) {
			g_error_free(error);
			error = NULL;
		}
	}
#endif /* USE_GSTREAMER */

	purple_signal_connect(blist_handle, "buddy-signed-on",
						gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
						GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE));
	purple_signal_connect(blist_handle, "buddy-signed-off",
						gtk_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
						GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE));
	purple_signal_connect(conv_handle, "received-im-msg",
						gtk_sound_handle, PURPLE_CALLBACK(im_msg_received_cb),
						GINT_TO_POINTER(PURPLE_SOUND_RECEIVE));
	purple_signal_connect(conv_handle, "sent-im-msg",
						gtk_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb),
						GINT_TO_POINTER(PURPLE_SOUND_SEND));
	purple_signal_connect(conv_handle, "chat-user-joined",
						gtk_sound_handle, PURPLE_CALLBACK(chat_user_join_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN));
	purple_signal_connect(conv_handle, "chat-user-left",
						gtk_sound_handle, PURPLE_CALLBACK(chat_user_left_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE));
	purple_signal_connect(conv_handle, "sent-chat-msg",
						gtk_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY));
	purple_signal_connect(conv_handle, "received-chat-msg",
						gtk_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
	purple_signal_connect(conv_handle, "got-attention", gtk_sound_handle,
						PURPLE_CALLBACK(got_attention_cb),
						  GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION));
	/* for the time being, don't handle sent-attention here, since playing a
	 sound would result induplicate sounds. And fixing that would require changing the
	 conversation signal for msg-recv */
}
//static
bool
MediaPluginGStreamer010::startup()
{
	// first - check if GStreamer is explicitly disabled
	if (NULL != getenv("LL_DISABLE_GSTREAMER"))
		return false;

	// only do global GStreamer initialization once.
	if (!mDoneInit)
	{
#if !GLIB_CHECK_VERSION(2, 36, 0)
#if !GLIB_CHECK_VERSION(2, 32, 0)
		if (!g_thread_supported()) g_thread_init(NULL);
#endif
		// Init the glib type system - we need it.
		g_type_init();
#endif
		set_gst_plugin_path();


/*
		// Get symbols!
#if LL_DARWIN
		if (! grab_gst_syms("libgstreamer-0.10.dylib",
				    "libgstvideo-0.10.dylib") )
#elseif LL_WINDOWS
		if (! grab_gst_syms("libgstreamer-0.10.dll",
				    "libgstvideo-0.10.dll") )
#else // linux or other ELFy unixoid
		if (! grab_gst_syms("libgstreamer-0.10.so.0",
				    "libgstvideo-0.10.so.0") )
#endif
		{
			WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled.");
			return false;
		}
*/
// 		if (gst_segtrap_set_enabled)
// 		{
			gst_segtrap_set_enabled(FALSE);
// 		}
// 		else
// 		{
// 			WARNMSG("gst_segtrap_set_enabled() is not available; plugin crashes won't be caught.");
// 		}
/*
#if LL_LINUX
		// Gstreamer tries a fork during init, waitpid-ing on it,
		// which conflicts with any installed SIGCHLD handler...
		struct sigaction tmpact, oldact;
		if (gst_registry_fork_set_enabled) {
			// if we can disable SIGCHLD-using forking behaviour,
			// do it.
			gst_registry_fork_set_enabled(false);
		}
		else {
			// else temporarily install default SIGCHLD handler
			// while GStreamer initialises
			tmpact.sa_handler = SIG_DFL;
			sigemptyset( &tmpact.sa_mask );
			tmpact.sa_flags = SA_SIGINFO;
			sigaction(SIGCHLD, &tmpact, &oldact);
		}
#endif // LL_LINUX
*/
		// Protect against GStreamer resetting the locale, yuck.
		static std::string saved_locale;
		saved_locale = setlocale(LC_ALL, NULL);

		// finally, try to initialize GStreamer!
		GError *err = NULL;
		gboolean init_gst_success = gst_init_check(NULL, NULL, &err);

		// restore old locale
		setlocale(LC_ALL, saved_locale.c_str() );
/*
#if LL_LINUX
		// restore old SIGCHLD handler
		if (!gst_registry_fork_set_enabled)
			sigaction(SIGCHLD, &oldact, NULL);
#endif // LL_LINUX
*/
		if (!init_gst_success) // fail
		{
			if (err)
			{
				WARNMSG("GST init failed: %s", err->message);
				g_error_free(err);
			}
			else
			{
				WARNMSG("GST init failed for unspecified reason.");
			}
			return false;
		}

		// Set up logging facilities
		gst_debug_remove_log_function( gst_debug_log_default );
//		gst_debug_add_log_function( gstreamer_log, NULL );

		// Init our custom plugins - only really need do this once.
		gst_slvideo_init_class();
/*
		// List the plugins GStreamer can find
		LL_DEBUGS("MediaImpl") << "Found GStreamer plugins:" << LL_ENDL;
		GList *list;
		GstRegistry *registry = gst_registry_get_default();
		std::string loaded = "";
		for (list = gst_registry_get_plugin_list(registry);
		     list != NULL;
		     list = g_list_next(list))
		{	 
			GstPlugin *list_plugin = (GstPlugin *)list->data;
			(bool)gst_plugin_is_loaded(list_plugin) ? loaded = "Yes" : loaded = "No";
			LL_DEBUGS("MediaImpl") << gst_plugin_get_name(list_plugin) << ", loaded? " << loaded << LL_ENDL;
		}
		gst_plugin_list_free(list);
*/
		mDoneInit = true;
	}

	return true;
}
예제 #23
0
int CGsCapture::Init()
{_STT();
	GstElement *pipeline, *camera_src, *screen_sink, *image_sink;
	GstElement *screen_queue, *image_queue;
	GstElement *csp_filter, *image_filter, *tee;
	GstCaps *caps;
	GstBus *bus;
	GMainLoop *loop;

	/* Initialize Gstreamer */
//	gst_init( 0, 0 );

oexM();
	GError *err = 0;
	if ( !gst_init_check( 0, 0, &err ) )
	{	oexSHOW( err->message );
		g_error_free( err );
		oexEcho( "gst_init_check() failed" );
		return -1;
	}
oexM();

	loop = g_main_loop_new (NULL, FALSE);
	oexSHOW( (int)loop );

	/* Create pipeline and attach a callback to it's
	 * message bus */
	pipeline = gst_pipeline_new("test-camera");

	bus = gst_pipeline_get_bus( GST_PIPELINE( pipeline ) );
	gst_bus_add_watch( bus, (GstBusFunc)bus_callback, loop );
	gst_object_unref( GST_OBJECT( bus ) );

/*
	GstElement *filesrc  = gst_element_factory_make ("filesrc", "my_filesource");
	if ( !filesrc )
	{
		oexEcho( "gst_element_factory_make() failed" );
		return -1;
	} // end if
*/

	/* Create elements */
	/* Camera video stream comes from a Video4Linux driver */
	camera_src = gst_element_factory_make("v4l2src", "camera_src");

//	gst_play_error_plugin (VIDEO_SRC, &err);

oexM();

	/* Colorspace filter is needed to make sure that sinks understands
	 * the stream coming from the camera */
	csp_filter = gst_element_factory_make("ffmpegcolorspace", "csp_filter");

oexM();

	/* Tee that copies the stream to multiple outputs */
	tee = gst_element_factory_make("tee", "tee");


	/* Queue creates new thread for the stream */
	screen_queue = gst_element_factory_make("queue", "screen_queue");


	/* Sink that shows the image on screen. Xephyr doesn't support XVideo
	 * extension, so it needs to use ximagesink, but the device uses
	 * xvimagesink */
	screen_sink = gst_element_factory_make(VIDEO_SINK, "screen_sink");
	/* Creates separate thread for the stream from which the image
	 * is captured */
	image_queue = gst_element_factory_make("queue", "image_queue");
	/* Filter to convert stream to use format that the gdkpixbuf library
	 * can use */
	image_filter = gst_element_factory_make("ffmpegcolorspace", "image_filter");

	/* A dummy sink for the image stream. Goes to bitheaven */
	image_sink = gst_element_factory_make("fakesink", "image_sink");

oexM();

	/* Check that elements are correctly initialized */
	if(!(pipeline && bus && camera_src && screen_sink && csp_filter && screen_queue
		&& image_queue && image_filter && image_sink))
	{
		oexSHOW( (long)pipeline );
		oexSHOW( (long)bus );
		oexSHOW( (long)camera_src );
		oexSHOW( (long)screen_sink );
		oexSHOW( (long)csp_filter );
		oexSHOW( (long)screen_queue );
		oexSHOW( (long)image_queue );
		oexSHOW( (long)image_filter );
		oexSHOW( (long)image_sink );

		oexEcho("Couldn't create pipeline elements");
		return -1;
	}

	/* Set image sink to emit handoff-signal before throwing away
	 * it's buffer */
	g_object_set(G_OBJECT(image_sink),
			"signal-handoffs", TRUE, NULL);

	/* Add elements to the pipeline. This has to be done prior to
	 * linking them */
	gst_bin_add_many(GST_BIN(pipeline), camera_src, csp_filter,
			tee, screen_queue, screen_sink, image_queue,
			image_filter, image_sink, NULL);

	/* Specify what kind of video is wanted from the camera */
	caps = gst_caps_new_simple("video/x-raw-rgb",
			"width", G_TYPE_INT, 640,
			"height", G_TYPE_INT, 480,
			NULL);


oexM();

	/* Link the camera source and colorspace filter using capabilities
	 * specified */
	if(!gst_element_link_filtered(camera_src, csp_filter, caps))
	{
		oexEcho( "gst_element_link_filtered() failed" );
		return -1;
	}
	gst_caps_unref(caps);

	/* Connect Colorspace Filter -> Tee -> Screen Queue -> Screen Sink
	 * This finalizes the initialization of the screen-part of the pipeline */
	if(!gst_element_link_many(csp_filter, tee, screen_queue, screen_sink, NULL))
	{
		oexEcho( "gst_element_link_many() failed" );
		return -1;
	}

	/* gdkpixbuf requires 8 bits per sample which is 24 bits per
	 * pixel */
	caps = gst_caps_new_simple("video/x-raw-rgb",
			"width", G_TYPE_INT, 640,
			"height", G_TYPE_INT, 480,
			"bpp", G_TYPE_INT, 24,
			"depth", G_TYPE_INT, 24,
			"framerate", GST_TYPE_FRACTION, 15, 1,
			NULL);

oexM();

	/* Link the image-branch of the pipeline. The pipeline is
	 * ready after this */
	if(!gst_element_link_many(tee, image_queue, image_filter, NULL))
	{	oexEcho( "gst_element_link_many() failed" );
		return -1;
	}

	if(!gst_element_link_filtered(image_filter, image_sink, caps))
	{	oexEcho( "gst_element_link_filtered() failed" );
		return -1;
	}

	gst_caps_unref(caps);

	/* As soon as screen is exposed, window ID will be advised to the sink */
//	g_signal_connect(appdata->screen, "expose-event", G_CALLBACK(expose_cb),
//			 screen_sink);

oexM();

	gst_element_set_state(pipeline, GST_STATE_PLAYING);

oexM();

	{ // Take snap shot

		GstElement *image_sink;

		/* Get the image sink element from the pipeline */
		image_sink = gst_bin_get_by_name(GST_BIN(pipeline),
				"image_sink");

		if ( !image_sink )
		{	oexEcho( "image_sink is null" );
			return -1;
		}


		/* Display a note to the user */
//		hildon_banner_show_information(GTK_WIDGET(appdata->window),
	//		NULL, "Taking Photo");

		/* Connect the "handoff"-signal of the image sink to the
		 * callback. This gets called whenever the sink gets a
		 * buffer it's ready to pass forward on the pipeline */
//		appdata->buffer_cb_id = g_signal_connect(
//				G_OBJECT(image_sink), "handoff",
//				G_CALLBACK(buffer_probe_callback), appdata);
	}

	return 0;
}
예제 #24
0
static GList *
gst_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
{
  /* This list is mainly from Totem. Generating a list from 
   * GStreamer isn't realistic, so we have to hardcode it. */
  /* See https://git.gnome.org/browse/totem/tree/data/mime-type-list.txt */
  static const char *mime_types[] = {
    "application/mxf",
    "application/ogg",
    "application/ram",
    "application/sdp",
    "application/smil",
    "application/smil+xml",
    "application/vnd.apple.mpegurl",
    "application/vnd.ms-wpl",
    "application/vnd.rn-realmedia",
    "application/x-extension-m4a",
    "application/x-extension-mp4",
    "application/x-flac",
    "application/x-flash-video",
    "application/x-matroska",
    "application/x-netshow-channel",
    "application/x-ogg",
    "application/x-quicktime-media-link",
    "application/x-quicktimeplayer",
    "application/x-shorten",
    "application/x-smil",
    "application/xspf+xml",
    "image/vnd.rn-realpix",
    "image/x-pict",
    "misc/ultravox",
    "text/google-video-pointer",
    "text/x-google-video-pointer",
    "video/3gp",
    "video/3gpp",
    "video/dv",
    "video/divx",
    "video/fli",
    "video/flv",
    "video/mp2t",
    "video/mp4",
    "video/mp4v-es",
    "video/mpeg",
    "video/msvideo",
    "video/ogg",
    "video/quicktime",
    "video/vivo",
    "video/vnd.divx",
    "video/vnd.mpegurl",
    "video/vnd.rn-realvideo",
    "video/vnd.vivo",
    "video/webm",
    "video/x-anim",
    "video/x-avi",
    "video/x-flc",
    "video/x-fli",
    "video/x-flic",
    "video/x-flv",
    "video/x-m4v",
    "video/x-matroska",
    "video/x-mpeg",
    "video/x-mpeg2",
    "video/x-ms-asf",
    "video/x-ms-asx",
    "video/x-msvideo",
    "video/x-ms-wm",
    "video/x-ms-wmv",
    "video/x-ms-wmx",
    "video/x-ms-wvx",
    "video/x-nsv",
    "video/x-ogm+ogg",
    "video/x-theora+ogg",
    "video/x-totem-stream",
    "x-content/video-dvd",
    "x-content/video-vcd",
    "x-content/video-svcd",
    NULL
  };
  GstThumbnailer    *thumbnailer;
  GError            *error = NULL;
  GStrv              uri_schemes;

  if (!gst_init_check (0, NULL, &error))
    {
      g_warning ("Cannot initialize GStreamer, thumbnailer not loaded: %s", 
                 error->message);
      return NULL;
    }

  uri_schemes = tumbler_util_get_supported_uri_schemes ();

  thumbnailer = g_object_new (TYPE_GST_THUMBNAILER,
                              "uri-schemes", uri_schemes,
                              "mime-types", mime_types,
                              NULL);

  g_strfreev (uri_schemes);

  return g_list_append (NULL, thumbnailer);
}
예제 #25
0
static void
finch_sound_init(void)
{
	void *gnt_sound_handle = finch_sound_get_handle();
	void *blist_handle = purple_blist_get_handle();
	void *conv_handle = purple_conversations_get_handle();
#ifdef USE_GSTREAMER
	GError *error = NULL;
#endif

	purple_signal_connect(purple_connections_get_handle(), "signed-on",
						gnt_sound_handle, PURPLE_CALLBACK(account_signon_cb),
						NULL);

	purple_prefs_add_none(FINCH_PREFS_ROOT "/sound");
	purple_prefs_add_string(FINCH_PREFS_ROOT "/sound/actprofile", DEFAULT_PROFILE);
	purple_prefs_add_none(FINCH_PREFS_ROOT "/sound/profiles");

	purple_prefs_connect_callback(gnt_sound_handle, FINCH_PREFS_ROOT "/sound/actprofile", initialize_profile, NULL);
	purple_prefs_trigger_callback(FINCH_PREFS_ROOT "/sound/actprofile");


#ifdef USE_GSTREAMER
	purple_debug_info("sound", "Initializing sound output drivers.\n");
#if (GST_VERSION_MAJOR > 0 || \
	(GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) || \
	 (GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 && GST_VERSION_MICRO >= 10))
	gst_registry_fork_set_enabled(FALSE);
#endif
	if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
		purple_notify_error(NULL, _("GStreamer Failure"),
					_("GStreamer failed to initialize."),
					error ? error->message : "");
		if (error) {
			g_error_free(error);
			error = NULL;
		}
	}
#endif /* USE_GSTREAMER */

	purple_signal_connect(blist_handle, "buddy-signed-on",
						gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
						GINT_TO_POINTER(PURPLE_SOUND_BUDDY_ARRIVE));
	purple_signal_connect(blist_handle, "buddy-signed-off",
						gnt_sound_handle, PURPLE_CALLBACK(buddy_state_cb),
						GINT_TO_POINTER(PURPLE_SOUND_BUDDY_LEAVE));
	purple_signal_connect(conv_handle, "received-im-msg",
						gnt_sound_handle, PURPLE_CALLBACK(im_msg_received_cb),
						GINT_TO_POINTER(PURPLE_SOUND_RECEIVE));
	purple_signal_connect(conv_handle, "sent-im-msg",
						gnt_sound_handle, PURPLE_CALLBACK(im_msg_sent_cb),
						GINT_TO_POINTER(PURPLE_SOUND_SEND));
	purple_signal_connect(conv_handle, "chat-buddy-joined",
						gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_join_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_JOIN));
	purple_signal_connect(conv_handle, "chat-buddy-left",
						gnt_sound_handle, PURPLE_CALLBACK(chat_buddy_left_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_LEAVE));
	purple_signal_connect(conv_handle, "sent-chat-msg",
						gnt_sound_handle, PURPLE_CALLBACK(chat_msg_sent_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_YOU_SAY));
	purple_signal_connect(conv_handle, "received-chat-msg",
						gnt_sound_handle, PURPLE_CALLBACK(chat_msg_received_cb),
						GINT_TO_POINTER(PURPLE_SOUND_CHAT_SAY));
	purple_signal_connect(conv_handle, "got-attention",
						gnt_sound_handle, PURPLE_CALLBACK(got_attention_cb),
						GINT_TO_POINTER(PURPLE_SOUND_GOT_ATTENTION));

	update_profiles();
}
예제 #26
0
/* entry point */
int
main (int argc, char **argv)
{
  GtkWidget *mainwin;
  gint n_burners;
  GError *error = NULL;
#ifdef HAVE_GUDEV
  gchar *error_msg;
#endif
  XfburnTranscoder *transcoder;
  XfburnDeviceList *devlist;

#if DEBUG > 0
  /* I have to disable this until GtkTreeView gets fixed,
   * and doesn't complain anymore when a DnD doesn't add any
   * rows
  g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL);
   */
#endif
  
  g_set_application_name (_("Xfburn"));

  gdk_threads_init ();
  gdk_threads_enter ();

  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");

  if (!gtk_init_with_args (&argc, &argv, "", optionentries, GETTEXT_PACKAGE, &error)) {
    if (error != NULL) {
      g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), PACKAGE, error->message, PACKAGE_NAME);
      g_error_free (error);
      return EXIT_FAILURE;
    }
  }

  if (!burn_initialize ()) {
    g_critical ("Unable to initialize libburn");
    xfce_dialog_show_error (NULL, NULL, _("Unable to initialize the burning backend."));
    gdk_threads_leave ();
    return EXIT_FAILURE;
  }

#ifdef HAVE_GST
  if (!gst_init_check (&argc, &argv, &error)) {
    g_critical ("Failed to initialize gstreamer!");
    /* I'm assuming this pretty much never happens. If it does, we should make this a soft failure and fall back to basic */
    gdk_threads_leave ();
    burn_finish ();
    return EXIT_FAILURE;
  }
#endif

  if (show_version) {
#ifdef HAVE_GST
    const char *nano_str;
    guint gst_major, gst_minor, gst_micro, gst_nano;
#endif

    g_print ("%s version %s for Xfce %s\n", PACKAGE, VERSION, xfce_version_string ());
    g_print ("\tbuilt with GTK+-%d.%d.%d, ", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
    g_print ("linked with GTK+-%d.%d.%d.\n", gtk_major_version, gtk_minor_version, gtk_micro_version);

#ifdef HAVE_GST
    gst_version (&gst_major, &gst_minor, &gst_micro, &gst_nano);

    if (gst_nano == 1)
      nano_str = " (CVS)";
    else if (gst_nano == 2)
      nano_str = " (Prerelease)";
    else
      nano_str = "";

    g_print ("\tGStreamer support (built with %d.%d.%d, linked against %d.%d.%d%s)\n",
             GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO,
             gst_major, gst_minor, gst_micro, nano_str);
             
#endif
    exit (EXIT_SUCCESS);
  }

  if (transcoder_selection && strcmp (transcoder_selection, "list") == 0) {
    print_available_transcoders();
    gdk_threads_leave ();
    burn_finish ();
    return EXIT_SUCCESS;
  }

  DBG ("%s version %s for Xfce %s\n", PACKAGE, VERSION, xfce_version_string ());

  xfburn_settings_init ();
  
#ifdef HAVE_GUDEV
  error_msg = xfburn_udev_manager_create_global ();
  if (error_msg) {
    xfce_dialog_show_error (NULL, NULL, "%s", error_msg);
    gdk_threads_leave ();
    burn_finish ();
    return EXIT_FAILURE;
  } else {
    g_message ("Using UDEV");
  }
#endif

  xfburn_stock_init ();
  devlist = xfburn_device_list_new ();
  g_object_get (devlist, "num-burners", &n_burners, NULL);

  if (n_burners < 1) {
    GtkMessageDialog *dialog = (GtkMessageDialog *) gtk_message_dialog_new (NULL,
                                    GTK_DIALOG_DESTROY_WITH_PARENT,
                                    GTK_MESSAGE_WARNING,
                                    GTK_BUTTONS_CLOSE,
                                    ((const gchar *) _("No burners are currently available")));
    gtk_message_dialog_format_secondary_text (dialog,
                                    _("Possibly the disc(s) are in use, and cannot get accessed.\n\n"
                                      "Please unmount and restart the application.\n\n"
                                      "If no disc is in the drive, check that you have read and write access to the drive with the current user."));
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (GTK_WIDGET (dialog));
  }


  /*----------Transcoder--------------------------------------------------*/

  if (!transcoder_selection) {
    /* select the best available */
#ifdef HAVE_GST
    transcoder = XFBURN_TRANSCODER (xfburn_transcoder_gst_new ());
#else
    transcoder = XFBURN_TRANSCODER (xfburn_transcoder_basic_new ());
#endif
#ifdef HAVE_GST
  } else if (strcmp (transcoder_selection, "gst") == 0) {
    transcoder = XFBURN_TRANSCODER (xfburn_transcoder_gst_new ());
#endif
  } else if (strcmp (transcoder_selection, "basic") == 0) {
    transcoder = XFBURN_TRANSCODER (xfburn_transcoder_basic_new ());
  } else {
    g_print ("'%s' is an invalid transcoder selection.\n",
             transcoder_selection);
    g_print ("\n");
    print_available_transcoders();
    gdk_threads_leave ();
    burn_finish ();
    return EXIT_FAILURE;
  }

  if (!xfburn_transcoder_is_initialized (transcoder, &error)) {
    xfce_dialog_show_warning(NULL, NULL, _("Failed to initialize %s transcoder: %s\n\t(falling back to basic implementation)"), xfburn_transcoder_get_name (transcoder), error->message);
    g_error_free (error);
    g_object_unref (transcoder);
    transcoder = XFBURN_TRANSCODER (xfburn_transcoder_basic_new ());
  } else {
    g_message ("Using %s transcoder.", xfburn_transcoder_get_name (transcoder));
  }
  xfburn_transcoder_set_global (transcoder);


  /*----------evaluate parsed command line action options-------------------------*/

  /* heuristic for file names on the commandline */
  if (argc == 2 && !add_data_composition && !add_audio_composition) {
    /* exactly one filename, assume it is an image */
      image_filename = argv[1];
  } else if (argc > 2) {
    /* several file names, for now just open up a data composition */
    /* TODO: auto-detect music files for audio compositions */
    add_data_composition = TRUE;
  }


  if (show_main) {
    xfburn_main_enter_main_window ();
  }

  if (image_filename != NULL) {
    GtkWidget *dialog = xfburn_burn_image_dialog_new ();
    other_action = TRUE;

    DBG ("image_filename = '%s'\n", image_filename);

    if (*image_filename != '\0') {
      gchar *image_fullname;

      if (!g_path_is_absolute (image_filename))
	image_fullname  = g_build_filename (g_get_current_dir (), image_filename, NULL);
      else
	image_fullname = image_filename;

      if (g_file_test (image_fullname, G_FILE_TEST_EXISTS))
	xfburn_burn_image_dialog_set_filechooser_name (dialog, image_fullname);
      else
        xfce_dialog_show_error (NULL, NULL, _("Image file '%s' does not exist."), image_fullname);
    }

    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
  } else if (blank) {
    GtkWidget *dialog = xfburn_blank_dialog_new ();

    other_action = TRUE;
    gtk_dialog_run (GTK_DIALOG (dialog));
    gtk_widget_destroy (dialog);
  }


  /*----------main window--------------------------------------------------*/

  if (!other_action || show_main) {
    xfburn_main_enter_main_window ();
    mainwin = xfburn_main_window_new ();

    gtk_widget_show (mainwin);
  
    if (add_data_composition)
      xfburn_main_window_add_data_composition_with_files (XFBURN_MAIN_WINDOW (mainwin), argc-1, argv+1);

    if (add_audio_composition)
      xfburn_main_window_add_audio_composition_with_files (XFBURN_MAIN_WINDOW (mainwin), argc-1, argv+1);
  }


  gtk_main ();


  /*----------shutdown--------------------------------------------------*/

  g_object_unref (devlist);
  g_object_unref (transcoder);

#ifdef HAVE_GUDEV
  xfburn_udev_manager_shutdown ();
#endif

  xfburn_settings_flush ();
  xfburn_settings_free ();
  
  burn_finish ();

  gdk_threads_leave ();

  return EXIT_SUCCESS;
}
예제 #27
0
static Eina_Bool
_gst_init(const char *filename)
{
   GstPad              *pad;
   GstCaps             *caps;
   GstStructure        *structure;
   gchar               *descr;
   gchar               *uri;
   GError              *error = NULL;
   GstFormat            format;
   GstStateChangeReturn ret;

   if (!filename || !*filename)
     return EINA_FALSE;

   if (!gst_init_check(NULL, NULL, &error))
     return EINA_FALSE;

   if ((*filename == '/') || (*filename == '~'))
     {
        uri = g_filename_to_uri(filename, NULL, NULL);
        if (!uri)
          {
             D("could not create new uri from %s", filename);
             goto unref_pipeline;
          }
     }
   else
     uri = strdup(filename);

   D("Setting file %s\n", uri);

   descr = g_strdup_printf("uridecodebin uri=%s ! ffmpegcolorspace ! "
      " appsink name=sink caps=\"" CAPS "\"", uri);
   pipeline = gst_parse_launch(descr, &error);
   free(uri);

   if (error != NULL)
     {
        D("could not construct pipeline: %s\n", error->message);
        g_error_free (error);
        goto gst_shutdown;
     }

   sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");

   ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
   switch (ret)
     {
     case GST_STATE_CHANGE_FAILURE:
        D("failed to play the file\n");
        goto unref_pipeline;
     case GST_STATE_CHANGE_NO_PREROLL:
        D("live sources not supported yet\n");
        goto unref_pipeline;
     default:
        break;
     }

   ret = gst_element_get_state((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE);
   if (ret == GST_STATE_CHANGE_FAILURE)
     {
	D("could not complete pause\n");
        goto unref_pipeline;
     }

   format = GST_FORMAT_TIME;
   gst_element_query_duration (pipeline, &format, &duration);
   if (duration == -1)
     {
	D("could not retrieve the duration, set it to 1s\n");
        duration = 1 * GST_SECOND;
     }

   pad = gst_element_get_static_pad(sink, "sink");
   if (!pad)
     {
	D("could not retrieve the sink pad\n");
        goto unref_pipeline;
     }

   caps = gst_pad_get_negotiated_caps(pad);
   if (!caps)
     goto unref_pad;

   structure = gst_caps_get_structure(caps, 0);

   if (!gst_structure_get_int(structure, "width", &width))
     goto unref_caps;
   if (!gst_structure_get_int(structure, "height", &height))
     goto unref_caps;

   gst_caps_unref(caps);
   gst_object_unref(pad);

   return EINA_TRUE;

 unref_caps:
   gst_caps_unref(caps);
 unref_pad:
   gst_object_unref(pad);
 unref_pipeline:
   gst_element_set_state (pipeline, GST_STATE_NULL);
   gst_object_unref(pipeline);
 gst_shutdown:
   gst_deinit();

   return EINA_FALSE;
}
/**
 * CGstMediaManager::Init().
 *
 * @param   data    user-defined data. Pointer to this.
 * @return  Java long reference to the media.
 */
uint32_t CGstMediaManager::Init()
{
    GError*     pError = NULL;
    uint32_t    uRetCode = ERROR_NONE;

#if ENABLE_LOWLEVELPERF && TARGET_OS_MAC
    g_mem_set_vtable (glib_mem_profiler_table);
#endif

#if ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION && TARGET_OS_WIN32
    _CrtSetDbgFlag ( 0 );
#endif // ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION

    //***** Try to initialize the GStreamer system
    if (!g_thread_supported())
        g_thread_init (NULL);

    LOWLEVELPERF_EXECTIMESTART("gst_init_check()");
    // disable installing SIGSEGV signal handling as it interferes with Java's signal handling
    gst_segtrap_set_enabled(false);
    if (!gst_init_check(NULL, NULL, NULL))
    {
        LOGGER_LOGMSG(LOGGER_DEBUG, "Could not init GStreamer!\n");
        return ERROR_MANAGER_ENGINEINIT_FAIL;
    }
    LOWLEVELPERF_EXECTIMESTOP("gst_init_check()");

#if ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION && TARGET_OS_WIN32
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif // ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION

    //***** Create mutex and condition variable
    m_pRunloopCond = g_cond_new();
    m_pRunloopMutex = g_mutex_new();

#if ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION && TARGET_OS_WIN32
    _CrtSetDbgFlag(0);
#endif // ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION

    //***** Create the primary run loop
    m_pMainLoopThread = g_thread_create((GThreadFunc)run_loop, this, FALSE, &pError);
    if (m_pMainLoopThread == NULL)
    {
        LOGGER_LOGMSG(LOGGER_DEBUG, "Could not create main GThread!!\n");
        LOGGER_LOGMSG(LOGGER_DEBUG, pError->message);
        return ERROR_MANAGER_RUNLOOP_FAIL;
    }

#if ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION && TARGET_OS_WIN32
    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif // ENABLE_VISUAL_STUDIO_MEMORY_LEAKS_DETECTION

    //***** Wait till the run loop has fully initialized.  Bad things happen if we do not do this, including crashers.
    g_mutex_lock(m_pRunloopMutex);
    while (NULL == m_pMainLoop)
        g_cond_wait(m_pRunloopCond, m_pRunloopMutex);
    g_mutex_unlock(m_pRunloopMutex);

    if (m_bMainLoopCreateFailed)
        uRetCode = ERROR_GSTREAMER_MAIN_LOOP_CREATE;

    // Free no longer needed GCond.
    if (NULL != m_pRunloopCond)
    {
        g_cond_free(m_pRunloopCond);
        m_pRunloopCond = NULL;
    }

    // Free no longer needed GMutex.
    if (NULL != m_pRunloopMutex)
    {
        g_mutex_free(m_pRunloopMutex);
        m_pRunloopMutex = NULL;
    }

    // Set the default Glib log handler.
    g_log_set_default_handler (GlibLogFunc, this);

    return uRetCode;
}
예제 #29
0
MainWindow::MainWindow()
    : MainWindowBase(0, "main window"),
      editPalette(palette()), previewPalette(palette()), previewstyle(0)
{
    modified = true;
    desktopThemeName = tr("Desktop Settings (Default)");
    setIcon(QPixmap(":/trolltech/qtconfig/images/appicon.png"));
    QStringList gstyles = QStyleFactory::keys();
    gstyles.sort();
    gstylecombo->addItem(desktopThemeName);
    gstylecombo->setItemData(gstylecombo->findText(desktopThemeName),
                                tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole);
    gstylecombo->insertStringList(gstyles);

    QSettings settings(QLatin1String("Trolltech"));
    settings.beginGroup(QLatin1String("Qt"));

    QString currentstyle = settings.value(QLatin1String("style")).toString();
    if (currentstyle.isEmpty()) {
        gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName));
        currentstyle = QLatin1String(QApplication::style()->name());
    } else {
        int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString);
        if (index != -1) {
            gstylecombo->setCurrentItem(index);
        } else { // we give up
            gstylecombo->insertItem(QLatin1String("Unknown"));
            gstylecombo->setCurrentItem(gstylecombo->count() - 1);
        }
    }
    buttonMainColor->setColor(palette().color(QPalette::Active,
                                              QColorGroup::Button));
    buttonMainColor2->setColor(palette().color(QPalette::Active,
                                               QColorGroup::Window));
    connect(buttonMainColor, SIGNAL(colorChanged(QColor)),
                this, SLOT(buildPalette()));
    connect(buttonMainColor2, SIGNAL(colorChanged(QColor)),
                this, SLOT(buildPalette()));

    if (X11->desktopEnvironment == DE_KDE)
        colorConfig->hide();
    else
        labelKDENote->hide();

    QFontDatabase db;
    QStringList families = db.families();
    familycombo->insertStringList(families);

    QStringList fs = families;
    QStringList fs2 = QFont::substitutions();
    QStringList::Iterator fsit = fs2.begin();
    while (fsit != fs2.end()) {
        if (! fs.contains(*fsit))
            fs += *fsit;
        fsit++;
    }
    fs.sort();
    familysubcombo->insertStringList(fs);

    choosesubcombo->insertStringList(families);
    Q3ValueList<int> sizes = db.standardSizes();
    Q3ValueList<int>::Iterator it = sizes.begin();
    while (it != sizes.end())
        psizecombo->insertItem(QString::number(*it++));

    dcispin->setValue(QApplication::doubleClickInterval());
    cfispin->setValue(QApplication::cursorFlashTime());
    wslspin->setValue(QApplication::wheelScrollLines());
    // #############
//    resolvelinks->setChecked(qt_resolve_symlinks);

    effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General));
    effectbase->setEnabled(effectcheckbox->isChecked());

    if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
        menueffect->setCurrentItem(2);
    else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu))
        menueffect->setCurrentItem(1);

    if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo))
        comboeffect->setCurrentItem(1);

    if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip))
        tooltipeffect->setCurrentItem(2);
    else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip))
        tooltipeffect->setCurrentItem(1);

    if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) )
        toolboxeffect->setCurrentItem( 1 );

    QSize globalStrut = QApplication::globalStrut();
    strutwidth->setValue(globalStrut.width());
    strutheight->setValue(globalStrut.height());

    // find the default family
    QStringList::Iterator sit = families.begin();
    int i = 0, possible = -1;
    while (sit != families.end()) {
        if (*sit == QApplication::font().family())
            break;
        if ((*sit).contains(QApplication::font().family()))
            possible = i;

        i++;
        sit++;
    }
    if (sit == families.end())
        i = possible;
    if (i == -1) // no clue about the current font
        i = 0;

    familycombo->setCurrentItem(i);

    QStringList styles = db.styles(familycombo->currentText());
    stylecombo->insertStringList(styles);

    QString stylestring = db.styleString(QApplication::font());
    sit = styles.begin();
    i = 0;
    possible = -1;
    while (sit != styles.end()) {
        if (*sit == stylestring)
            break;
        if ((*sit).contains(stylestring))
            possible = i;

        i++;
        sit++;
    }
    if (sit == styles.end())
        i = possible;
    if (i == -1) // no clue about the current font
        i = 0;
    stylecombo->setCurrentItem(i);

    i = 0;
    for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) {
        const int sz = psizecombo->text(i).toInt();
        if (sz == psize) {
            psizecombo->setCurrentItem(i);
            break;
        } else if(sz > psize) {
            psizecombo->insertItem(i, QString::number(psize));
            psizecombo->setCurrentItem(i);
            break;
        }
    }

    QStringList subs = QFont::substitutes(familysubcombo->currentText());
    sublistbox->clear();
    sublistbox->insertStringList(subs);

    rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool());

#ifdef Q_WS_X11
    inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString());
#else
    inputStyle->hide();
    inputStyleLabel->hide();
#endif

#if defined(Q_WS_X11) && !defined(QT_NO_XIM)
    QStringList inputMethods = QInputContextFactory::keys();
    int inputMethodIndex = -1;
    QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString();
    for (int i = inputMethods.size()-1; i >= 0; --i) {
        const QString &im = inputMethods.at(i);
        if (im.contains(QLatin1String("imsw"))) {
            inputMethods.removeAt(i);
            if (inputMethodIndex > i)
                --inputMethodIndex;
        } else if (im == defaultInputMethod) {
            inputMethodIndex = i;
        }
    }
    if (inputMethodIndex == -1 && !inputMethods.isEmpty())
        inputMethodIndex = 0;
    inputMethod->addItems(inputMethods);
    inputMethod->setCurrentIndex(inputMethodIndex);
#else
    inputMethod->hide();
    inputMethodLabel->hide();
#endif

    fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool());
    fontpaths = settings.value(QLatin1String("fontPath")).toStringList();
    fontpathlistbox->insertStringList(fontpaths);

    audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto"));
    audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")),
                                tr("Choose audio output automatically."), Qt::ToolTipRole);
    audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink"));
    audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")),
                                tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole);
#ifdef HAVE_PHONON
    phononVersionLabel->setText(QLatin1String(Phonon::phononVersion()));
#endif
#ifndef QT_NO_GSTREAMER
    if (gst_init_check(0, 0, 0)) {
        gchar *versionString = gst_version_string();
        gstversionLabel->setText(QLatin1String(versionString));
        g_free(versionString);
        GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY);
        QString name, klass, description;
        for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) {
            GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data);
            klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature)));
            if (klass == QLatin1String("Sink/Audio")) {
                name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature));
                if (name == QLatin1String("sfsink"))
                    continue; //useless to output audio to file when you cannot set the file path
                else if (name == QLatin1String("autoaudiosink"))
                    continue; //This is used implicitly from the auto setting
                GstElement *sink = gst_element_factory_make (qPrintable(name), NULL);
                if (sink) {
                    description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature)));
                    audiosinkCombo->addItem(name, name);
                    audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole);
                    gst_object_unref (sink);
                }
            }
        }
        g_list_free(factoryList);
    }
#else
    tab4->setEnabled(false);
    phononLabel->setText(tr("Phonon GStreamer backend not available."));
#endif

    videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto"));
    videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole);
#ifdef Q_WS_X11
    videomodeCombo->addItem(tr("X11"), QLatin1String("X11"));
    videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole);
#endif
#ifndef QT_NO_OPENGL
    videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL"));
    videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole);
#endif
    videomodeCombo->addItem(tr("Software"), QLatin1String("Software"));
    videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole);

    QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString();
    QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString();
    audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink));
    videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode));

    settings.endGroup(); // Qt

    helpview->setText(tr(appearance_text));

    setModified(false);
    updateStyleLayout();
}
예제 #30
0
파일: drawapp.cpp 프로젝트: Strongc/szarp
bool DrawApp::OnInit() {


	/* Read params from szarp.cfg. */
#if wxUSE_UNICODE
	libpar_read_cmdline_w(&argc, argv);
#else
	libpar_read_cmdline(&argc, argv);
#endif

#if BOOST_FILESYSTEM_VERSION == 3
	boost::filesystem::wpath::imbue(std::locale("C")); 	
#else
	boost::filesystem::wpath_traits::imbue(std::locale("C")); 	
#endif

	if (!DrawGLApp::OnInit())
		return false;


	SetProgName(_T("Draw 3"));
	//signal(SIGINT, INThandler);

	if (m_just_print_version) {
		std::cout << SZARP_VERSION << std::endl;
		return false;
	}
	m_server = NULL;
	m_db_queue = NULL;
	m_executor = NULL;
	m_remarks_handler = NULL;

#ifdef __WXGTK__
	libpar_init();

	char *base = NULL;
	if (m_base == wxEmptyString) {
		base = libpar_getpar("", "config_prefix", 1);
		m_base = SC::L2S(base);
		free(base);
	}

	{

		if (m_base_type != IKS_BASE) {
			char *iks_server = libpar_getpar("draw3", "iks_server", 0);
			if (iks_server) {
				m_iks_server = SC::L2S(iks_server);
				m_base_type = IKS_BASE;
				free(iks_server);
			}

			char *iks_port = libpar_getpar("draw3", "iks_server_port", 0);
			if (iks_port) {
				m_iks_port = SC::L2S(iks_port);
				free(iks_port);
			}
		}
	}

	m_probers_from_szarp_cfg = get_probers_addresses();
#endif

#ifdef MINGW32
	WORD wVersionRequested = MAKEWORD(2, 2);
	WSADATA wsaData;
	WSAStartup(wVersionRequested, &wsaData);
#endif
	/* Set logging to stderr. */
	wxLog *logger = new wxLogStderr();
	//wxLog *logger = new wxLogGui();
	wxLog::SetActiveTarget(logger);


	m_instance = new szSingleInstanceChecker(_T(".szarp_m_instance_lock"), wxEmptyString, 
			_T("draw3"));
	if (m_instance->IsAnotherRunning()) {
		if (!m_url.IsEmpty()) {
			if (m_url_open_in_existing)
				SendToRunningInstance(_T("START_URL"), m_url.c_str());
			else
				SendToRunningInstance(_T("START_URL_EXISTING"), m_url.c_str());
		} else if (!m_base.IsEmpty()) {		
			SendToRunningInstance(_T("START_BASE"), m_base.c_str());
		} else {
			wxLogError(_T("base not given"));
			return false;
		}
		return false;
	}
        

	InitGL();

	SplashScreen *splash = NULL;
	wxBitmap bitmap;

	// this loads draw64_xpm under Linux, or draw64 icon resource under Windows
	szFrame::setDefaultIcon(wxICON(draw64));

	wxString splashimage = GetSzarpDir();

#ifndef MINGW32
	splashimage += _T("resources/wx/images/szarp-logo.png");
#else
	splashimage += _T("resources\\wx\\images\\szarp-logo.png");
#endif

#if wxUSE_LIBPNG
	/* Activate PNG image handler. */
	wxImage::AddHandler( new wxPNGHandler );
#endif

	if (bitmap.LoadFile(splashimage, wxBITMAP_TYPE_PNG))
		splash = new SplashScreen(&bitmap);
	else
		splash = new SplashScreen();
	splash->Show(true);

	splash->PushStatusText(_("Setting locale..."));
	
	/* Set locale. */
	this->InitializeLocale(_T("draw3"), locale);

	splash->PushStatusText(_("Reading params from szarp.cfg..."));

	wxString _lang = wxConfig::Get()->Read(_T("LANGUAGE"), AUTO_LANGUAGE);
	if (_lang == AUTO_LANGUAGE)
		_lang = DEFAULT_LANGUAGE;

	splash->PushStatusText(_("Initializing IPKContainer..."));
	IPKContainer::Init(GetSzarpDataDir().c_str(), 
			GetSzarpDir().c_str(), 
			_lang.c_str());
	m_cfg_mgr = new ConfigManager(GetSzarpDataDir(), IPKContainer::GetObject());

	m_cfg_mgr->SetSplashScreen(splash);

	splash->PushStatusText(_("Initializing szbase..."));

	splash->PushStatusText(_("Initializing XML Resources..."));
    
	InitXmlResource();

	splash->PushStatusText(_("Starting database query mechanism..."));

	m_db_queue = new DatabaseQueryQueue();
	m_dbmgr = new DatabaseManager(m_db_queue, m_cfg_mgr);
	m_db_queue->SetDatabaseManager(m_dbmgr);
	m_dbmgr->SetProbersAddresses(GetProbersAddresses());

	Draw3Base* draw_base;
	switch (m_base_type) {
		case SZBASE_BASE:
			draw_base = new SzbaseBase(m_dbmgr, GetSzarpDataDir().c_str(),
				&ConfigurationFileChangeHandler::handle,
				wxConfig::Get()->Read(_T("SZBUFER_IN_MEMORY_CACHE"), 0L));
			break;
		case SZ4_BASE:
			draw_base = new Sz4Base(m_dbmgr, GetSzarpDataDir().c_str(),
				IPKContainer::GetObject());
			break;
		case IKS_BASE:
			draw_base = new Sz4ApiBase(m_dbmgr, m_iks_server.c_str(), m_iks_port.c_str(),
				IPKContainer::GetObject());
			break;
	}

	m_executor = new QueryExecutor(m_db_queue, m_dbmgr, draw_base);
	m_executor->Create();
	m_executor->SetPriority((WXTHREAD_MAX_PRIORITY + WXTHREAD_DEFAULT_PRIORITY) / 2);
	m_executor->Run();

	m_cfg_mgr->SetDatabaseManager(m_dbmgr);

	ConfigurationFileChangeHandler::database_manager = m_dbmgr;

	/* default config */
	wxString defid;

	DrawsSets *config = NULL;

	splash->PushStatusText(_("Loading configuration..."));

	/* init activity logger with base name as server name. This assumes that 
	 * server has written basename to /etc/hosts on linux machines and probably
	 * doesn't work on windows.
	 */
	UDPLogger::SetAppName( "draw3" );
	UDPLogger::SetAddress( (const char*)m_base.mb_str(wxConvUTF8) );
	UDPLogger::SetPort   ( "7777" );
	UDPLogger::LogEvent  ( "drawapp:start" );



	wxString prefix, window;
	PeriodType pt = PERIOD_T_YEAR;
	time_t time = -1;
	int selected_draw = 0;

	if (!m_url.IsEmpty()) {
		if (!decode_url(m_url, prefix, window, pt, time, selected_draw)) {
			wxLogError(_T("Invalid URL"));
			StopThreads();
			return FALSE;
		}
	} else if (!m_base.IsEmpty()) {
		if ((config = m_cfg_mgr->LoadConfig(m_base,std::wstring(),m_show_logparams)) == NULL) {
			wxLogError(_("Error occurred while loading default configuration. Check your szarp.cfg file."));
			StopThreads();
			return FALSE;
		}
		prefix = m_base;
	} else {
		wxLogError(_("Missing starting base specification."));
		StopThreads();
		return FALSE;
	}


#ifndef MINGW32
	libpar_done();
#endif

	m_help = new szHelpController;
#ifndef MINGW32
	m_help->AddBook(wxGetApp().GetSzarpDir() + L"/resources/documentation/new/draw3/html/draw3.hhp");
#else
	m_help->AddBook(wxGetApp().GetSzarpDir() + L"\\resources\\documentation\\new\\draw3\\html\\draw3.hhp");
#endif
	szHelpControllerHelpProvider* provider = new szHelpControllerHelpProvider;
	wxHelpProvider::Set(provider);
	provider->SetHelpController(m_help);

	splash->PushStatusText(_("Initizalizing remarks..."));
	
	m_remarks_handler = new RemarksHandler(m_cfg_mgr);
	m_remarks_handler->Start();
	
	splash->PushStatusText(_("Creating Frame Manager..."));

	VersionChecker* version_checker = new VersionChecker(argv[0]);
	version_checker->Start();

	FrameManager *fm = new FrameManager(m_dbmgr, m_cfg_mgr, m_remarks_handler);

	/*@michal  */
	if (!fm->CreateFrame(prefix, window, pt, time, wxSize(width, height), wxPoint(x, y), selected_draw, m_url.IsEmpty(), m_full_screen)) {
		StopThreads();
		wxLogError(_T("Unable to load base: %s"), prefix.c_str());
		return FALSE;
	}

	StartInstanceServer(fm, m_cfg_mgr);

	wxToolTip::SetDelay(1000);
    
	SetAppName(_T("SZARPDRAW3"));

	splash->Destroy();

	m_cfg_mgr->ResetSplashScreen();

#ifndef NO_GSTREAMER
	if (!gst_init_check(NULL, NULL, NULL)) 
		return 1;
#endif

	return TRUE;
}