Beispiel #1
0
/**
 * Gives the previous actor plugin based on the name of a plugin but skips
 * GL plugins.
 *
 * @see visual_actor_get_next_by_name_nogl
 *
 * @param name The name of the current plugin or NULL to get the last.
 *
 * @return The name of the previous plugin within the list that is not a GL plugin.
 */
const char *visual_actor_get_prev_by_name_nogl (const char *name)
{
	const char *prev = name;
	VisPluginData *plugin;
	VisPluginRef *ref;
	VisActorPlugin *actplugin;
	int gl;

	do {
		prev = visual_plugin_get_prev_by_name (visual_actor_get_list (), prev);

		if (prev == NULL)
			return NULL;
		
		ref = visual_plugin_find (__lv_plugins_actor, prev);
		plugin = visual_plugin_load (ref);
		actplugin = VISUAL_ACTOR_PLUGIN (plugin->info->plugin);

		if ((actplugin->vidoptions.depth & VISUAL_VIDEO_DEPTH_GL) > 0)
			gl = TRUE;
		else
			gl = FALSE;
	
		visual_plugin_unload (plugin);

	} while (gl == TRUE);

	return prev;
}
Beispiel #2
0
static gboolean
plugin_init (GstPlugin * plugin)
{
  guint i, count;
  VisList *list;

  GST_DEBUG_CATEGORY_INIT (libvisual_debug, "libvisual", 0,
      "libvisual audio visualisations");

#ifdef LIBVISUAL_PLUGINSBASEDIR
  gst_plugin_add_dependency_simple (plugin, "HOME/.libvisual/actor",
      LIBVISUAL_PLUGINSBASEDIR "/actor", NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE);
#endif

  visual_log_set_verboseness (VISUAL_LOG_VERBOSENESS_LOW);
  visual_log_set_info_handler (libvisual_log_handler, (void *) GST_LEVEL_INFO);
  visual_log_set_warning_handler (libvisual_log_handler,
      (void *) GST_LEVEL_WARNING);
  visual_log_set_critical_handler (libvisual_log_handler,
      (void *) GST_LEVEL_ERROR);
  visual_log_set_error_handler (libvisual_log_handler,
      (void *) GST_LEVEL_ERROR);

  if (!visual_is_initialized ())
    if (visual_init (NULL, NULL) != 0)
      return FALSE;

  list = visual_actor_get_list ();

#if !defined(VISUAL_API_VERSION)
  count = visual_list_count (list);
#elif VISUAL_API_VERSION >= 4000 && VISUAL_API_VERSION < 5000
  count = visual_collection_size (VISUAL_COLLECTION (list));
#endif

  for (i = 0; i < count; i++) {
    VisPluginRef *ref = visual_list_get (list, i);
    VisPluginData *visplugin = NULL;
    gboolean skip = FALSE;
    GType type;
    gchar *name;
    GTypeInfo info = {
      sizeof (GstVisualClass),
      NULL,
      NULL,
      gst_visual_class_init,
      NULL,
      ref,
      sizeof (GstVisual),
      0,
      NULL
    };

    visplugin = visual_plugin_load (ref);

    if (ref->info->plugname == NULL)
      continue;

    /* Blacklist some plugins */
    if (strcmp (ref->info->plugname, "gstreamer") == 0 ||
        strcmp (ref->info->plugname, "gdkpixbuf") == 0) {
      skip = TRUE;
    } else {
      /* Ignore plugins that only support GL output for now */
      skip = gst_visual_actor_plugin_is_gl (visplugin->info->plugin,
          visplugin->info->plugname);
    }

    visual_plugin_unload (visplugin);

    if (!skip) {
      name = g_strdup_printf ("GstVisual%s", ref->info->plugname);
      make_valid_name (name);
      type = g_type_register_static (GST_TYPE_VISUAL, name, &info, 0);
      g_free (name);

      name = g_strdup_printf ("libvisual_%s", ref->info->plugname);
      make_valid_name (name);
      if (!gst_element_register (plugin, name, GST_RANK_NONE, type)) {
        g_free (name);
        return FALSE;
      }
      g_free (name);
    }
  }

  return TRUE;
}
Beispiel #3
0
/**
 * Gives the previous actor plugin based on the name of a plugin.
 *
 * @see visual_actor_get_next_by_name
 * 
 * @param name The name of the current plugin. or NULL to get the last.
 *
 * @return The name of the previous plugin within the list.
 */
const char *visual_actor_get_prev_by_name (const char *name)
{
	return visual_plugin_get_prev_by_name (visual_actor_get_list (), name);
}
Beispiel #4
0
int
main( int argc, char** argv )
{
    if( argc <= 1 || std::strcmp( argv[1], "--list" ) == 0 )
    {
        visual_init( &argc, &argv );

        #if 0
        VisList *list = visual_actor_get_list();

        for( VisListEntry *entry = list->head->next; entry != list->tail; entry = entry->next )
        {
            VisPluginInfo *info = static_cast<VisActor*>(entry->data)->plugin->ref->info;

            std::cout << info->name << '|' << info->about << std::endl;
        }
        #endif

        const char *plugin = 0;

        while( (plugin = visual_actor_get_next_by_name( plugin )) )
            std::cout << plugin << '\n';

        std::exit( 0 );
    }
    else if( argc == 3 )
        Vis::plugin = argv[2];


    //connect to socket
    const int sockfd = tryConnect( argv[1] );

    //register fd/pid combo with Pana
    {
        pid_t pid = ::getpid();
        char  buf[32] = "REG";
        *(pid_t*)&buf[4] = pid;

        ::send( sockfd, buf, 4 + sizeof(pid_t), 0 );
    }

    //init
    SDL::init();
    Vis::init( argc, argv );


    //main loop
    // 1. we sleep for a bit, listening for messages from Pana
    // 2. render a frame

    timeval tv;
    fd_set  fds;
    int     nbytes = 0;
    uint    render_time = 0;

    while( nbytes != -1 && SDL::event_handler() )
    {
        //set the time to wait
        tv.tv_sec  = 0;
        tv.tv_usec = render_time > 16 ? 0 : (16 - render_time) * 1000; //60Hz

        //get select to watch the right file descriptor
        FD_ZERO( &fds );
        FD_SET( sockfd, &fds );

        ::select( sockfd+1, &fds, 0, 0, &tv );

        if( FD_ISSET( sockfd, &fds) ) {
            //Pana sent us some data

            char command[16];
            ::recv( sockfd, command, 16, 0 );

            if( std::strcmp( command, "fullscreen" ) == 0 )
                SDL::toggleFullScreen();
        }

        //request pcm data
        ::send( sockfd, "PCM", 4, 0 );
        nbytes = ::recv( sockfd, Vis::pcm_data, 1024 * sizeof( int16_t ), 0 );

        render_time = LibVisual::render();
    }

    ::close( sockfd );

    return 0;
}