diff options
author | Michael Roitzsch <mroi@users.sourceforge.net> | 2002-12-01 14:52:55 +0000 |
---|---|---|
committer | Michael Roitzsch <mroi@users.sourceforge.net> | 2002-12-01 14:52:55 +0000 |
commit | bf7f88dbb589de79422d59843f4990f2d1f6ffec (patch) | |
tree | 669550a2c2be69b6d9bc2eb467e511d7e076c269 /src/xine-engine | |
parent | 15db4b0085815fcfd6179a26b894e962c5a65878 (diff) | |
download | xine-lib-bf7f88dbb589de79422d59843f4990f2d1f6ffec.tar.gz xine-lib-bf7f88dbb589de79422d59843f4990f2d1f6ffec.tar.bz2 |
first Advent - time for some presents: xine's first post plugin
CVS patchset: 3398
CVS date: 2002/12/01 14:52:55
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/post.c | 168 | ||||
-rw-r--r-- | src/xine-engine/post.h | 118 |
2 files changed, 286 insertions, 0 deletions
diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c new file mode 100644 index 000000000..c65e53400 --- /dev/null +++ b/src/xine-engine/post.c @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine 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. + * + * xine 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 + * + * $Id: post.c,v 1.1 2002/12/01 14:52:55 mroi Exp $ + */ + +/* + * some helper functions for post plugins + */ + +#include "post.h" + + +/* dummy intercept functions that just pass the call on to the original port */ +static uint32_t post_video_get_capabilities(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + return port->original_port->get_capabilities(port->original_port); +} + +static void post_video_open(xine_video_port_t *port_gen, xine_stream_t *stream) { + post_video_port_t *port = (post_video_port_t *)port_gen; + port->original_port->open(port->original_port, stream); +} + +static vo_frame_t *post_video_get_frame(xine_video_port_t *port_gen, uint32_t width, + uint32_t height, int ratio_code, int format, int flags) { + post_video_port_t *port = (post_video_port_t *)port_gen; + return port->original_port->get_frame(port->original_port, + width, height, ratio_code, format, flags); +} + +static vo_frame_t *post_video_get_last_frame(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + return port->original_port->get_last_frame(port->original_port); +} + +static void post_video_enable_ovl(xine_video_port_t *port_gen, int ovl_enable) { + post_video_port_t *port = (post_video_port_t *)port_gen; + port->original_port->enable_ovl(port->original_port, ovl_enable); +} + +static void post_video_close(xine_video_port_t *port_gen, xine_stream_t *stream) { + post_video_port_t *port = (post_video_port_t *)port_gen; + port->original_port->close(port->original_port, stream); +} + +static void post_video_exit(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + port->original_port->exit(port->original_port); +} + +static video_overlay_instance_t *post_video_get_overlay_instance(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + return port->original_port->get_overlay_instance(port->original_port); +} + +static void post_video_flush(xine_video_port_t *port_gen) { + post_video_port_t *port = (post_video_port_t *)port_gen; + port->original_port->flush(port->original_port); +} + + +post_video_port_t *post_intercept_video_port(xine_video_port_t *original) { + post_video_port_t *post_port = (post_video_port_t *)malloc(sizeof(post_video_port_t)); + + if (!post_port) + return NULL; + + post_port->port.get_capabilities = post_video_get_capabilities; + post_port->port.open = post_video_open; + post_port->port.get_frame = post_video_get_frame; + post_port->port.get_last_frame = post_video_get_last_frame; + post_port->port.enable_ovl = post_video_enable_ovl; + post_port->port.close = post_video_close; + post_port->port.exit = post_video_exit; + post_port->port.get_overlay_instance = post_video_get_overlay_instance; + post_port->port.flush = post_video_flush; + post_port->port.driver = original->driver; + + post_port->original_port = original; + + return post_port; +} + + +/* functions intercepting frame calls */ +static void post_frame_free(vo_frame_t *vo_img) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + post_restore_video_frame(vo_img, port); + vo_img->free(vo_img); +} + +static void post_frame_copy(vo_frame_t *vo_img, uint8_t **src) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + vo_img->port = port->original_port; + port->original_frame.copy(vo_img, src); + vo_img->port = &port->port; +} + +static void post_frame_field(vo_frame_t *vo_img, int which_field) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + vo_img->port = port->original_port; + port->original_frame.field(vo_img, which_field); + vo_img->port = &port->port; +} + +static int post_frame_draw(vo_frame_t *vo_img, xine_stream_t *stream) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + post_restore_video_frame(vo_img, port); + return vo_img->draw(vo_img, stream); +} + +static void post_frame_displayed(vo_frame_t *vo_img) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + post_restore_video_frame(vo_img, port); + vo_img->displayed(vo_img); +} + +static void post_frame_dispose(vo_frame_t *vo_img) { + post_video_port_t *port = (post_video_port_t *)vo_img->port; + post_restore_video_frame(vo_img, port); + vo_img->dispose(vo_img); +} + + +void post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *port) { + port->original_frame.port = frame->port; + port->original_frame.free = frame->free; + port->original_frame.copy = frame->copy; + port->original_frame.field = frame->field; + port->original_frame.draw = frame->draw; + port->original_frame.displayed = frame->displayed; + port->original_frame.dispose = frame->dispose; + + frame->port = &port->port; + frame->free = post_frame_free; + frame->copy = frame->copy ? post_frame_copy : NULL; /* this one can be NULL */ + frame->field = post_frame_field; + frame->draw = post_frame_draw; + frame->displayed = post_frame_displayed; + frame->dispose = post_frame_dispose; +} + +void post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port) { + frame->port = port->original_port; + frame->free = port->original_frame.free; + frame->copy = port->original_frame.copy; + frame->field = port->original_frame.field; + frame->draw = port->original_frame.draw; + frame->displayed = port->original_frame.displayed; + frame->dispose = port->original_frame.dispose; +} diff --git a/src/xine-engine/post.h b/src/xine-engine/post.h new file mode 100644 index 000000000..373480c46 --- /dev/null +++ b/src/xine-engine/post.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2000-2002 the xine project + * + * This file is part of xine, a free video player. + * + * xine 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. + * + * xine 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 + * + * $Id: post.h,v 1.1 2002/12/01 14:52:56 mroi Exp $ + * + * post plugin definitions + * + */ + +#ifndef XINE_POST_H +#define XINE_POST_H + +#include "xine.h" +#include "video_out.h" +#include "xineutils.h" + +#define POST_PLUGIN_IFACE_VERSION 1 + + +typedef struct post_class_s post_class_t; +typedef struct post_plugin_s post_plugin_t; + + +struct post_class_s { + + /* + * open a new instance of this plugin class + */ + post_plugin_t* (*open_plugin) (post_class_t *this, int inputs, + xine_audio_port_t **audio_target, + xine_video_port_t **video_target); + + /* + * return short, human readable identifier for this plugin class + */ + char* (*get_identifier) (post_class_t *this); + + /* + * return human readable (verbose = 1 line) description for + * this plugin class + */ + char* (*get_description) (post_class_t *this); + + /* + * free all class-related resources + */ + + void (*dispose) (post_class_t *this); +}; + +struct post_plugin_s { + + /* public part of the plugin */ + xine_post_t xine_post; + + /* + * the connections announced by the plugin + * the plugin must fill these with xine_post_{in,out}_t on init + */ + xine_list_t *input; + xine_list_t *output; + + /* + * close down, free all resources + */ + void (*dispose) (post_plugin_t *this); + + /* plugins don't have to care for the stuff below */ + + /* used when the user requests a list of all inputs/outputs */ + const char **input_ids; + const char **output_ids; + + /* used by plugin loader */ + void *node; +}; + + +/* helper structure for intercepting video port calls */ +typedef struct post_video_port_s post_video_port_t; +struct post_video_port_s { + + /* the new public port with replaced function pointers */ + xine_video_port_t port; + + /* the original port to call its functions from inside yours */ + xine_video_port_t *original_port; + + /* here you can keep information about the frames */ + vo_frame_t original_frame; +}; + +/* use this to create a new video port in which port functions can + * be replaced with own implementation */ +post_video_port_t *post_intercept_video_port(xine_video_port_t *port); + +/* use this to modify a frame to so that functions can be replaced + * with own implementations */ +void post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *port); +void post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port); + +#endif |