From af8b0038e7cbd5b58a30d5eb7883c2307f86c10a Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Thu, 26 Apr 2001 11:31:35 +0000 Subject: load video plugin function implementation, + support in video out plugins (xv for now). CVS patchset: 27 CVS date: 2001/04/26 11:31:35 --- src/video_out/video_out_xv.c | 44 +++++++++- src/xine-engine/load_plugins.c | 185 +++++++++++++++++----------------------- src/xine-engine/video_out.h | 12 ++- src/xine-engine/xine_internal.h | 18 +++- 4 files changed, 148 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 00cc8c18d..14516ca80 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out_xv.c,v 1.1 2001/04/24 20:53:00 f1rmb Exp $ + * $Id: video_out_xv.c,v 1.2 2001/04/26 11:31:35 f1rmb Exp $ * * video_out_xv.c, X11 video extension interface for xine * @@ -52,6 +52,9 @@ #include #include "video_out.h" +#include "xine_internal.h" + +#define VO_OUT_XV_IFACE_VERSION 1 /* override xprintf definition */ #define xprintf(LVL, FMT, ARGS...) { printf(FMT, ##ARGS); } @@ -660,9 +663,15 @@ static void xv_check_capability (xv_driver_t *this, uint32_t capability, int pro xv_set_property (&this->vo_driver, property, this->config->lookup_int (this->config, str_prop, nDefault) ); } -vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { +static char *xv_get_identifier(void) { + return "X11_XV"; +} + +vo_driver_t *init_video_out_xv (int iface, config_values_t *config, + void *visual, int visual_type) { xv_driver_t *this; + Display *display = NULL; unsigned int adaptor_num, adaptors, i, j, formats; unsigned int ver,rel,req,ev,err; unsigned int xv_port; @@ -679,6 +688,33 @@ vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { XineramaScreenInfo *screeninfo = NULL; #endif + if(iface > VO_OUT_XV_IFACE_VERSION || iface <= 0) { + printf("%s: wrong interface version, current = %d, wanted = %d\n", + __FILE__, VIDEO_OUT_PLUGIN_IFACE_VERSION, iface); + return NULL; + } + + switch(visual_type) { + + case VIDEO_OUTPUT_TYPE_GETID: + this = malloc (sizeof (xv_driver_t)); + memset (this, 0, sizeof(xv_driver_t)); + this->vo_driver.interface_version = VO_OUT_XV_IFACE_VERSION; + this->vo_driver.get_identifier = xv_get_identifier; + + return &this->vo_driver; + break; + + case VIDEO_OUTPUT_TYPE_X11: + display = (Display *) visual; + break; + + defaut: + printf("%s: Wrong output type (%d)\n", __FILE__, visual_type); + return NULL; + break; + } + /* * check for Xvideo support */ @@ -713,6 +749,7 @@ vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { adaptor_num++; } + if (!xv_port) { printf ("video_out_xv: Xv extension is present but I couldn't find a usable yuv12 port.\n"); printf (" Looks like your graphics hardware driver doesn't support Xv?!\n"); @@ -735,6 +772,7 @@ vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { this->capabilities = 0; this->config = config; + this->vo_driver.interface_version = VO_OUT_XV_IFACE_VERSION; this->vo_driver.get_capabilities = xv_get_capabilities; this->vo_driver.alloc_frame = xv_alloc_frame; this->vo_driver.update_frame_format = xv_update_frame_format; @@ -746,6 +784,7 @@ vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { this->vo_driver.get_window = xv_get_window; this->vo_driver.set_logo_mode = xv_set_logo_mode; this->vo_driver.exit = xv_exit; + this->vo_driver.get_identifier = xv_get_identifier; if (XAllocNamedColor (display, DefaultColormap (display, this->screen), "black", &this->black, &ignored) == 0) { @@ -901,3 +940,4 @@ vo_driver_t *init_video_out_xv (Display *display, config_values_t *config) { } #endif + diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index b80f1e929..f16aee4d5 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: load_plugins.c,v 1.6 2001/04/24 17:42:27 guenter Exp $ + * $Id: load_plugins.c,v 1.7 2001/04/26 11:31:36 f1rmb Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -38,6 +38,7 @@ #include "xine_internal.h" #include "demuxers/demux.h" #include "input/input_plugin.h" +#include "video_out.h" #include "metronom.h" #include "configfile.h" #include "monitor.h" @@ -49,6 +50,12 @@ void load_demux_plugins (xine_t *this, config_values_t *config, int iface_version) { DIR *dir; + if(this == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null, exiting\n", + __FILE__, __FUNCTION__, __LINE__); + exit(1); + } + this->num_demuxer_plugins = 0; dir = opendir (XINE_PLUGINDIR) ; @@ -121,6 +128,12 @@ void load_input_plugins (xine_t *this, config_values_t *config, int iface_version) { DIR *dir; + if(this == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null, exiting\n", + __FILE__, __FUNCTION__, __LINE__); + exit(1); + } + this->num_input_plugins = 0; dir = opendir (XINE_PLUGINDIR) ; @@ -129,7 +142,6 @@ void load_input_plugins (xine_t *this, struct dirent *pEntry; while ((pEntry = readdir (dir)) != NULL) { - char str[1024]; void *plugin; @@ -196,6 +208,12 @@ void load_decoder_plugins (xine_t *this, DIR *dir; int i; + if(this == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null, exiting\n", + __FILE__, __FUNCTION__, __LINE__); + exit(1); + } + /* * clean up first */ @@ -308,28 +326,43 @@ void load_decoder_plugins (xine_t *this, void load_video_out_plugins (xine_t *this, config_values_t *config, int iface_version) { + if(this == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null, exiting\n", + __FILE__, __FUNCTION__, __LINE__); + exit(1); + } + } void load_audio_out_plugins (xine_t *this, config_values_t *config, int iface_version) { + if(this == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null, exiting\n", + __FILE__, __FUNCTION__, __LINE__); + exit(1); + } + } -/* -vo_instance_t *load_video_output_plugin(char *filename, char *id) { +vo_driver_t *load_video_output_plugin(config_values_t *config, + char *filename, char *id, + int visual_type, void *visual) { DIR *dir; - vo_instance_t *voi; + vo_driver_t *vod; - if(filename == NULL && id == NULL) + if((filename == NULL && id == NULL) || visual == NULL || config == NULL) { + printf("%s(%s@%d): parameter should be non null\n", + __FILE__, __FUNCTION__, __LINE__); return NULL; - + } + dir = opendir (XINE_PLUGINDIR); - + if (dir) { struct dirent *pEntry; while ((pEntry = readdir (dir)) != NULL) { - char str[1024]; void *plugin; @@ -339,12 +372,12 @@ vo_instance_t *load_video_output_plugin(char *filename, char *id) { XINE_VIDEO_OUT_PLUGIN_PREFIXNAME, XINE_VIDEO_OUT_PLUGIN_PREFIXNAME_LENGTH) == 0) && ((pEntry->d_name[nLen-3]=='.') - && (pEntry->d_name[nLen-2]=='s') - && (pEntry->d_name[nLen-1]=='o'))) { + && (pEntry->d_name[nLen-2]=='s') + && (pEntry->d_name[nLen-1]=='o'))) { sprintf (str, "%s/%s", XINE_PLUGINDIR, pEntry->d_name); - if(filename) { + if(filename) { /* load by name */ if(!strncasecmp(filename, pEntry->d_name, strlen(filename))) { if(!(plugin = dlopen (str, RTLD_LAZY))) { @@ -353,105 +386,53 @@ vo_instance_t *load_video_output_plugin(char *filename, char *id) { exit(1); } else { - void *(*initplug) (int, config_values_t *); + void *(*initplug) (int, config_values_t *, int, void *); if((initplug = dlsym(plugin, "init_video_out_plugin")) != NULL) { - video_out_plugin_t *vop; - vop = (video_out_plugin_t *) initplug(iface_version, config); - this->video_out_plugins[this->num_input_plugins] = vop; + vod = (vo_driver_t *) initplug(VIDEO_OUT_PLUGIN_IFACE_VERSION, + config, visual_type, visual); - printf("video output plugin found : %s(ID: %s, iface: %d)\n", - str, - this->input_plugins[this->num_input_plugins].get_identifier(), - this->input_plugins[this->num_input_plugins].interface_version); - - - if((voi = xmalloc(sizeof(vo_instance_t))) != NULL) { - voi = - } - } - -*/ /* - if(!(plugin = dlopen (str, RTLD_LAZY))) { - fprintf(stderr, "%s(%d): %s doesn't seem to be installed (%s)\n", - __FILE__, __LINE__, str, dlerror()); - exit(1); - } - else { - void *(*initplug) (int, config_values_t *); - - if((initplug = dlsym(plugin, "init_demuxer_plugin")) != NULL) { - input_plugin_t *ip; - - ip = (input_plugin_t *) initplug(iface_version, config); - this->input_plugins[this->num_input_plugins] = *ip; - - printf("input plugin found : %s(ID: %s, iface: %d)\n", - str, - this->input_plugins[this->num_input_plugins].get_identifier(), - this->input_plugins[this->num_input_plugins].interface_version); - - this->num_input_plugins++; + printf("video output plugin found : %s(ID: %s, iface: %d)\n", + str, vod->get_identifier(), vod->interface_version); + + return vod; + } + } } - - */ - - - /* - * input plugin found => load it - */ -/* - sprintf (str, "%s/%s", XINE_PLUGINDIR, pEntry->d_name); - - if(!(plugin = dlopen (str, RTLD_LAZY))) { - fprintf(stderr, "%s(%d): %s doesn't seem to be installed (%s)\n", - __FILE__, __LINE__, str, dlerror()); - exit(1); } - else { - void *(*initplug) (int, config_values_t *); - - if((initplug = dlsym(plugin, "init_demuxer_plugin")) != NULL) { - input_plugin_t *ip; - - ip = (input_plugin_t *) initplug(iface_version, config); - this->input_plugins[this->num_input_plugins] = *ip; - - printf("input plugin found : %s(ID: %s, iface: %d)\n", - str, - this->input_plugins[this->num_input_plugins].get_identifier(), - this->input_plugins[this->num_input_plugins].interface_version); - - this->num_input_plugins++; - } + else { /* load by ID */ - if(this->num_input_plugins > INPUT_PLUGIN_MAX) { - fprintf(stderr, "%s(%d): too many input plugins installed, " - "exiting.\n", __FILE__, __LINE__); + if(!(plugin = dlopen (str, RTLD_LAZY))) { + fprintf(stderr, "%s(%d): %s doesn't seem to be installed (%s)\n", + __FILE__, __LINE__, str, dlerror()); exit(1); } + else { + void *(*initplug) (int, config_values_t *, int, void *); + + if((initplug = dlsym(plugin, "init_video_out_plugin")) != NULL) { + + vod = (vo_driver_t *) initplug(VIDEO_OUT_PLUGIN_IFACE_VERSION, + config, visual_type, visual); + + printf("video output plugin found : %s(ID: %s, iface: %d)\n", + str, vod->get_identifier(), vod->interface_version); + + if(!strcasecmp(id, vod->get_identifier())) { + return vod; + } + } + } } } } } - - if (this->num_input_plugins == 0) { - printf ("No input plugins found in %s! - " - "Did you install xine correctly??\n", XINE_PLUGINDIR); - exit (1); - } + return NULL; } -*/ -char **enum_video_output_plugins(int output_type) { - /* - Add into xine.h and xine_internal.h - VIDEO_OUTPUT_TYPE_ALL - VIDEO_OUTPUT_TYPE_X11 - VIDEO_OUTPUT_TYPE_FB - ... - */ +char **enum_video_output_plugins(int visual_type) { + // Not implemented return NULL; } @@ -465,15 +446,9 @@ ao_functions_t *load_audio_output_plugin(char *filename, char *id) { return NULL; } char **enum_audio_output_plugins(int output_type) { - /* - Add into xine.h and xine_internal.h - not sure about names !! - AUDIO_OUTPUT_TYPE_ALL - AUDIO_OUTPUT_TYPE_OSS - AUDIO_OUTPUT_TYPE_ALSA - AUDIO_OUTPUT_TYPE_ESD - ... - */ + + // Not implemented + return NULL; } diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h index a6ed08231..b26adb614 100644 --- a/src/xine-engine/video_out.h +++ b/src/xine-engine/video_out.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out.h,v 1.1 2001/04/24 20:53:00 f1rmb Exp $ + * $Id: video_out.h,v 1.2 2001/04/26 11:31:36 f1rmb Exp $ * * * xine version of video_out.h @@ -216,6 +216,11 @@ struct vo_instance_s { struct vo_driver_s { + /* + * plugin interface version, lower versions _may_ be supported + */ + int interface_version; + uint32_t (*get_capabilities) (vo_driver_t *this); /* for constants see below */ /* @@ -249,6 +254,11 @@ struct vo_driver_s { void (*set_logo_mode) (vo_driver_t *this, int show_logo); void (*exit) (vo_driver_t *this); + + /* + * return human readable identifier for this plugin + */ + char* (*get_identifier) (void); }; diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 140a637ef..17b17a108 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -1,4 +1,4 @@ -/* + /* * Copyright (C) 2000-2001 the xine project * * This file is part of xine, a unix video player. @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_internal.h,v 1.10 2001/04/24 21:10:42 guenter Exp $ + * $Id: xine_internal.h,v 1.11 2001/04/26 11:31:36 f1rmb Exp $ * */ @@ -341,5 +341,17 @@ void load_audio_out_plugins (xine_t *this, config_values_t *config, int iface_version); void load_decoder_plugins (xine_t *this, config_values_t *config, int iface_version); - +/* visual_type (see bellow) */ +#define VIDEO_OUTPUT_TYPE_GETID 0 +#define VIDEO_OUTPUT_TYPE_PROBE 1 +#define VIDEO_OUTPUT_TYPE_X11 2 +#define VIDEO_OUTPUT_TYPE_FB 3 +vo_driver_t *load_video_output_plugin(config_values_t *config, + char *filename, char *id, + int visual_type, void *visual); +#define AUDIO_OUTPUT_TYPE_GETID 0 +#define AUDIO_OUTPUT_TYPE_PROBE 1 +#define AUDIO_OUTPUT_TYPE_OSS 2 +#define AUDIO_OUTPUT_TYPE_ALSA 3 +#define AUDIO_OUTPUT_TYPE_ESD 4 #endif -- cgit v1.2.3