/* ** Copyright (C) 2002-2004 Daniel Caujolle-Bert ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include "common.h" extern int errno; /* #define LOCAL_BUILD 1 */ #ifdef LOCAL_BUILD #undef TOXINE_PLUGINDIR #define TOXINE_PLUGINDIR "plugins/.libs" #endif /* * Load video output plugins. */ void toxine_load_vo_plugins (toxine_t *tox) { DIR *dir; if(tox == NULL) { fprintf(stderr, "%s(%s@%d): toxine_t * parameter should be non null, exiting\n", __FILE__, __tox_func__, __LINE__); exit(1); } tox->video.plugins_num = 0; dir = opendir(TOXINE_PLUGINDIR) ; if(dir) { struct dirent *pf; while((pf = readdir(dir)) != NULL) { char str[1024]; void *plugin; int nlen = strlen(pf->d_name); if((strncasecmp(pf->d_name, "toxine_vo_plugin", 16) == 0) && ((pf->d_name[nlen-3]=='.') && (pf->d_name[nlen-2]=='s') && (pf->d_name[nlen-1]=='o'))) { sprintf(str, "%s/%s", TOXINE_PLUGINDIR, pf->d_name); if(!(plugin = dlopen(str, RTLD_LAZY))) { fprintf(stderr, "%s(%s@%d): cannot open demux plugin %s:\n%s\n", __FILE__, __tox_func__, __LINE__, str, dlerror()); } else { void *(*initplug) (toxine_t *); if((initplug = dlsym(plugin, "toxine_load_vo_plugin")) != NULL) { toxine_vo_plugin_t *vop; vop = (toxine_vo_plugin_t *) initplug(tox); if(vop) { char buffer[2048]; int j; tox->video.plugins[tox->video.plugins_num] = vop; memset(&buffer, 0, sizeof(buffer)); sprintf(buffer, "%s", "+ supporting:"); sprintf(buffer, "video out plugin '%s' found ( ", tox->video.plugins[tox->video.plugins_num]->get_identifier()); { char **vonames = (char **)tox->video.plugins[tox->video.plugins_num]->get_names(); for(j = 0; vonames[j] != NULL; j++) sprintf(buffer, "%s%s ", buffer, vonames[j]); } sprintf(buffer, "%s).\n", buffer); pinfo(buffer); tox->video.plugins_num++; } } if(tox->video.plugins_num > TOXINE_VO_PLUGINS_MAX) { fprintf(stderr, "%s(%s@%d): too many video out plugins installed, exiting.\n", __FILE__, __tox_func__, __LINE__); exit(1); } } } } closedir(dir); } else { fprintf(stderr, "Can't open plugin directory: '%s'\nGiving up.\n", TOXINE_PLUGINDIR); exit(1); } tox->video.cur_plugin = NULL; tox->video.last_plugin = NULL; }