Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 7a7f1b6944a25663039b7e0c7848225f > files > 23

xdtv-devel-2.4.0-7mdv2009.0.i586.rpm

Since version 2.0.0 the plugins have been a lot simplified.

Here is an example of a very simple plugin:

---------- exampleplugin.c  ---------------------
/* a simple plugin, which inverses red and blue when
   the key 'F2' is pressed */
#include "plugin.h"

unsigned int version = XDTV_PLUGIN_API;

static int invert(vop2 *v, unsigned char *dest,
		  unsigned char *src, int w, int h) {
  int i;
  for(i=w*h/2;i>0;i--, dest+=4, src+=4) {
    dest[0]=src[0];
    dest[1]=src[3];
    dest[2]=src[2];
    dest[3]=src[1];
  }
  return 1;
}

static vop invertvop = {
  "redblueinvert",
  2,            /* only 1 image is necessary */
  VIDEO_YUYV,   /* source format */
  VIDEO_YUYV,   /* destination format */
  &invert ,     /* THE function */
  NULL,        /* no initializer */
  0,           /* no constraint on the source width */
  0,           /* no constraint on the source height */
  0,    /* no constraint on the destination height */
  1     /* 1 means post-filter */
};

static void invertinit(void) {
  char *keys="<Key>F2: VOP(redblueinvert)\n";
  XtOverrideTranslations (tv, XtParseTranslationTable (keys));
}

void _init(void) {
  vop_register(&invertvop);
  register_initaction(invertinit);
}
---------- end exampleplugin.c ---------------------

To test this plugin compile it with:

gcc -nostartfiles -shared -Wall -I/usr/local/include/xdtv \
    exampleplugin.c -o exampleplugin.so

You can test it with:

xdtv -plugin ./exampleplugin.so 

(press the F2 in the main window of xdtv to see that the image changes)

If you want this plugin to be loaded everytime do:

mkdir -p /usr/local/lib/xdtv-plugins
cp exampleplugin.so /usr/local/lib/xdtv-plugins

(replace "/usr/local/" by "/usr/" if xdtv had been installed in /usr)