Index: xine_fbfe_frontend.c
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine_fbfe_frontend.c,v
retrieving revision 1.12
diff -U2 -r1.12 xine_fbfe_frontend.c
--- xine_fbfe_frontend.c	14 Mar 2007 10:26:39 -0000	1.12
+++ xine_fbfe_frontend.c	1 Apr 2007 09:21:26 -0000
@@ -176,4 +176,19 @@
 }
 
+static int fbfe_display_open_2(frontend_t *this_gen)
+{
+  return fbfe_display_open(this_gen,
+			   this_gen->config.width,
+			   this_gen->config.height,
+			   this_gen->config.fullscreen,
+			   this_gen->config.modeswitch,
+			   this_gen->config.modeline,
+			   this_gen->config.aspect,
+			   this_gen->config.keypresshandler,
+			   this_gen->config.video_port,
+			   this_gen->config.scale_video,
+			   this_gen->config.field_order);
+}
+
 /*
  * fbfe_display_config
@@ -276,4 +294,8 @@
 #endif /*#ifndef FE_STANDALONE */
 
+  this->fe.fe_display_open_2   = fbfe_display_open_2;
+  //this->fe.fe_display_config_2 = fbfe_display_config_2;
+  this->fe.xine_init_2  = fe_xine_init_2;
+
   return (frontend_t*)this;
 }
Index: xine_frontend.c
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine_frontend.c,v
retrieving revision 1.33
diff -U2 -r1.33 xine_frontend.c
--- xine_frontend.c	14 Mar 2007 10:23:15 -0000	1.33
+++ xine_frontend.c	1 Apr 2007 09:21:26 -0000
@@ -460,5 +460,5 @@
 	   "%s%s", xine_get_homedir(), 
 	  "/.xine/config_xineliboutput");
-  
+  this->configfile[sizeof(this->configfile)-1] = 0;
   xine_config_load (this->xine, this->configfile);
 
@@ -640,4 +640,16 @@
 }
 
+static int fe_xine_init_2(frontend_t *this_gen)
+{
+  return fe_xine_init(this_gen,
+		      this_gen->config.audio_driver,
+		      this_gen->config.audio_port,
+		      this_gen->config.video_driver,
+		      this_gen->config.pes_buffers,
+		      this_gen->config.priority,
+		      this_gen->config.post_chain);
+}
+
+
 /*
  * fe_xine_open
Index: xine_frontend.h
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine_frontend.h,v
retrieving revision 1.5
diff -U2 -r1.5 xine_frontend.h
--- xine_frontend.h	23 Aug 2006 05:27:11 -0000	1.5
+++ xine_frontend.h	1 Apr 2007 09:21:27 -0000
@@ -20,21 +20,21 @@
 typedef void (*fe_keypress_f)(const char *keymap, const char *name);
 
-typedef struct frontend_config_s frontend_config_t;
+typedef struct fe_config_s fe_config_t;
 typedef struct frontend_s frontend_t;
 
-#if 0
-struct frontend_config_s {
+struct fe_config_s {
   /* Display */
-  int width; 
-  int height;
-  int fullscreen;
-  int modeswitch; 
+  int   width; 
+  int   height;
+  int   fullscreen;
+  int   modeswitch; 
   char *modeline;
-  int aspect;
+  int   aspect;
+  int   window_id;
                           
   char *video_port;
                           
-  int scale_video;
-  int field_order;
+  int   scale_video;
+  int   field_order;
 
   fe_keypress_f keypresshandler;
@@ -44,8 +44,8 @@
   char *audio_port;
   char *video_driver;
-  int pes_buffers;
-  int priority;
+  char *post_chain;
+  int   pes_buffers;
+  int   priority;
 };
-#endif
 
 struct frontend_s {
@@ -88,9 +88,14 @@
   char *(*grab)(frontend_t*, int *size, int jpeg, int quality,
 		int width, int height);
-#if 0
-  frontend_config_t config;
-#endif
+
+
+  int (*fe_display_open_2)(frontend_t*);
+  int (*fe_display_config_2)(frontend_t *);
+  int (*xine_init_2)(frontend_t*);
+
+  fe_config_t config;
 };
 
+
 typedef frontend_t *(*fe_creator_f)(void);
 
Index: xine_frontend_main.c
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine_frontend_main.c,v
retrieving revision 1.29
diff -U2 -r1.29 xine_frontend_main.c
--- xine_frontend_main.c	17 Mar 2007 12:14:37 -0000	1.29
+++ xine_frontend_main.c	1 Apr 2007 09:21:27 -0000
@@ -282,9 +282,13 @@
     "                                 drivers: auto, alsa, oss, arts, esound, none\n"
     "   --video=videodriver[:device]  Select video driver and optional port\n"
-    "                                 X11: auto, x11, xshm, xv, xvmc, xxmc, vidix,\n"
+#ifndef IS_FBFE
+    "                                      auto, x11, xshm, xv, xvmc, xxmc, vidix,\n"
     "                                      sdl, opengl, none\n"
-    "                                 framebuffer: auto, fb, DirectFB, vidixfb,\n"
-    "                                      sdl, dxr3, aadxr3, none\n"
     "   --display=displayaddress      X11 display address\n"
+    "   --wid=id                      Use existing X11 window\n"
+#else
+    "                                      auto, fb, DirectFB, vidixfb,\n"
+    "                                      sdl, dxr3, aadxr3, none\n"
+#endif
     "   --aspect=[auto|4:3|16:9|16:10|default] Display aspect ratio\n"
     "   --fullscreen                  Fullscreen mode\n"
@@ -318,4 +322,5 @@
   { "video",      required_argument, NULL, 'V' },
   { "display",    required_argument, NULL, 'd' },
+  { "wid",        required_argument, NULL, 'W' },
   { "aspect",     required_argument, NULL, 'a' },
   { "fullscreen", no_argument,       NULL, 'f' },
@@ -344,15 +349,31 @@
 int main(int argc, char *argv[])
 {
-  char *mrl = NULL, *gdrv = NULL, *adrv = NULL, *adev = NULL;
+  fe_config_t config = {
+    width:        720,
+    height:       576,
+    fullscreen:   0,
+    modeswitch:   0,
+    modeline:     NULL,
+    aspect:       1,
+    window_id:    -1,
+    video_port:   NULL,
+    scale_video:  1,
+    field_order:  0,
+    keypresshandler: NULL,
+    
+    audio_driver: NULL,
+    audio_port:   NULL,
+    video_driver: NULL,
+    post_chain:   NULL,
+    pes_buffers:  250,
+    priority:     1,
+  };
+  char *mrl = NULL;
   int ftcp = 0, fudp = 0, frtp = 0, reconnect = 0, firsttry = 1;
-  int fullscreen = 0, width = 720, height = 576;
-  int scale_video = 1, aspect = 1;
   int daemon_mode = 0, nokbd = 0, slave_mode = 0;
-  char *video_port = NULL;
   int xmajor, xminor, xsub;
   int err, c;
   frontend_t *fe = NULL;
   extern const fe_creator_f fe_creator;
-  char *static_post_plugins = NULL;
   char *lirc_dev = NULL;
   int repeat_emu = 0;
@@ -377,51 +398,54 @@
               printf("%s", help_str);
 	      exit(0);
-    case 'A': adrv = strdup(optarg);
-              adev = strchr(adrv, ':');
-	      if(adev)
-	        *(adev++) = 0;
-	      PRINTF("Audio driver: %s\n",adrv);
-	      if(adev)
-		PRINTF("Audio device: %s\n",adev);
-	      break;
-    case 'V': gdrv = strdup(optarg);
-              if(strchr(gdrv, ':')) {
-		video_port = strchr(gdrv, ':');
-		*video_port = 0;
-		video_port++;
-		PRINTF("Video port: %s\n",video_port);
+    case 'A': config.audio_driver = strdup(optarg);
+              config.audio_port = strchr(config.audio_driver, ':');
+	      if(config.audio_port)
+	        *(config.audio_port++) = 0;
+	      PRINTF("Audio driver: %s\n", config.audio_driver);
+	      if(config.audio_port)
+		PRINTF("Audio device: %s\n", config.audio_port);
+	      break;
+    case 'V': config.video_driver = strdup(optarg);
+              if(strchr(config.video_driver, ':')) {
+		config.video_port = strchr(config.video_driver, ':');
+		*(config.video_port++) = 0;
+		PRINTF("Video port: %s\n", config.video_port);
 	      }
-              PRINTF("Video driver: %s\n",gdrv);
+              PRINTF("Video driver: %s\n", config.video_driver);
+              break;
+#ifndef IS_FBFE
+    case 'W': config.window_id = atoi(optarg);
               break;
-    case 'd': video_port = strdup(optarg);
+    case 'd': config.video_port = strdup(optarg);
               break;
+#endif
     case 'a': if(!strncmp(optarg, "auto", 4))
-                aspect = 0;
+                config.aspect = 0;
               if(!strncmp(optarg, "4:3", 3))
-		aspect = 2;
+		config.aspect = 2;
 	      if(!strncmp(optarg, "16:9", 4))
-		aspect = 3;
+		config.aspect = 3;
 	      if(!strncmp(optarg, "16:10", 5))
-		aspect = 4;
+		config.aspect = 4;
 	      PRINTF("Aspect ratio: %s\n", 
-		     aspect==0?"Auto":aspect==2?"4:3":aspect==3?"16:9":
-		     aspect==4?"16:10":"Default");
+		     config.aspect==0?"Auto":config.aspect==2?"4:3":
+		     config.aspect==3?"16:9":config.aspect==4?"16:10":"Default");
 	      break;
-    case 'f': fullscreen=1;
+    case 'f': config.fullscreen = 1;
               PRINTF("Fullscreen mode\n");
 	      break;
-    case 'w': width = atoi(optarg);
-              PRINTF("Width: %d\n", width);
+    case 'w': config.width = atoi(optarg);
+              PRINTF("Width: %d\n", config.width);
 	      break;
-    case 'h': height = atoi(optarg);
-              PRINTF("Height: %d\n", height);
+    case 'h': config.height = atoi(optarg);
+              PRINTF("Height: %d\n", config.height);
 	      break;
-    case 'n': scale_video = 0;
+    case 'n': config.scale_video = 0;
               PRINTF("Video scaling disabled\n");
 	      break;
-    case 'P': if(static_post_plugins)
-                strcatrealloc(static_post_plugins, ";");
-              static_post_plugins = strcatrealloc(static_post_plugins, optarg);
-	      PRINTF("Post plugins: %s\n", static_post_plugins);
+    case 'P': if(config.post_chain)
+                config.post_chain = strcatrealloc(config.post_chain, ";");
+              config.post_chain = strcatrealloc(config.post_chain, optarg);
+	      PRINTF("Post plugins: %s\n", config.post_chain);
 	      break;
     case 'L': lirc_dev = optarg ? : strdup("/dev/lircd");
@@ -549,8 +573,9 @@
     return -3;
   }
+  memcpy(&fe->config, &config, sizeof(fe_config_t));
 
   /* Initialize display */
-  if(!fe->fe_display_open(fe, width, height, fullscreen, 0, 
-			  "", aspect, NULL, video_port, scale_video, 0)) {
+  if(!fe->fe_display_open_2(fe) /*, width, height, fullscreen, 0, 
+		  "", aspect, NULL, video_port, scale_video, 0)*/) {
     fprintf(stderr, "Error opening display\n");
     fe->fe_free(fe);
@@ -559,5 +584,5 @@
 
   /* Initialize xine */
-  if(!fe->xine_init(fe, adrv, adev, gdrv, 250, 1, static_post_plugins)) {
+  if(!fe->xine_init_2(fe /*, adrv, adev, gdrv, 250, 1, static_post_plugins*/)) {
     fprintf(stderr, "Error initializing xine\n");
     fe->fe_free(fe);
Index: xine_sxfe_frontend.c
===================================================================
RCS file: /cvsroot/xineliboutput/vdr-xineliboutput/xine_sxfe_frontend.c,v
retrieving revision 1.20
diff -U2 -r1.20 xine_sxfe_frontend.c
--- xine_sxfe_frontend.c	14 Mar 2007 10:25:32 -0000	1.20
+++ xine_sxfe_frontend.c	1 Apr 2007 09:22:53 -0000
@@ -128,4 +128,5 @@
   int                      field_order;
   char                     modeline[256];
+  int                      window_id;
 
   int                      fullscreen_state_forced;
@@ -188,4 +189,7 @@
   XEvent ev;
 
+  if(this->window_id > 0)
+    return;
+
   if(this->atom_state == None) {
     this->atom_win_layer        = XInternAtom(this->display, "_WIN_LAYER", False);
@@ -234,4 +238,7 @@
   MWMHints   mwmhints;
 
+  if(this->window_id > 0)
+    return;
+
   this->no_border = border ? 0 : 1;
 
@@ -250,7 +257,16 @@
   long propvalue[1];
 
+  if(this->window_id > 0)
+    return;
+
   this->stay_above = stay_above;
 
+#ifdef FE_STANDALONE
   XStoreName(this->display, this->window[0], stay_above ? "VDR (top)" : "VDR");
+  //const char *mrl = this->stream->input_plugin->mrl(this->stream->input_plugin);
+  //** available only after connection !
+#else
+  XStoreName(this->display, this->window[0], stay_above ? "Local VDR (top)" : "Local VDR");
+#endif
 
   memset(&ev, 0, sizeof(ev));
@@ -362,5 +378,5 @@
   if(keyfunc) {
     this->keypress = keyfunc;
-    this->keypress("XKeySym", ""); /* triggers learning mode */
+    this->keypress("XKeySym", ""); /* triggers learning mode (in local mode) */
   }
 
@@ -385,5 +401,6 @@
   this->overscan        = 0;
   this->fullscreen_state_forced = 0;
-  strn0cpy(this->modeline, modeline, sizeof(this->modeline));
+  if(modeline)
+    strn0cpy(this->modeline, modeline, sizeof(this->modeline));
 
   /*
@@ -447,13 +464,19 @@
   }
   
-  /* create and display our video window */
-  this->window[0] = XCreateSimpleWindow (this->display,
-					 DefaultRootWindow(this->display),
-					 this->xpos, this->ypos,
-					 this->width, this->height,
-					 1, 0, 0);
-  this->window[1] = XCreateSimpleWindow(this->display, XDefaultRootWindow(this->display),
-					0, 0, (DisplayWidth(this->display, this->screen)),
-					(DisplayHeight(this->display, this->screen)), 0, 0, 0);
+  if(this->window_id > 0) {
+    LOGDBG("sxfe_diaplay_open(): Using X11 window %d for output", this->window_id);
+    this->window[0] = this->window[1] = (Window)this->window_id;
+    XUnmapWindow(this->display, this->window[0]);
+  } else {
+    /* create and display our video window */
+    this->window[0] = XCreateSimpleWindow (this->display,
+					   DefaultRootWindow(this->display),
+					   this->xpos, this->ypos,
+					   this->width, this->height,
+					   1, 0, 0);
+    this->window[1] = XCreateSimpleWindow(this->display, XDefaultRootWindow(this->display),
+					  0, 0, (DisplayWidth(this->display, this->screen)),
+					  (DisplayHeight(this->display, this->screen)), 0, 0, 0);
+  }
 
   hint.flags  = USSize | USPosition | PPosition | PSize;
@@ -464,14 +487,16 @@
   XSetNormalHints(this->display, this->window[1], &hint);
 
-  /* full-screen window */
-  set_fullscreen_props(this);
-
-  /* no border in fullscreen window */
-  this->atom_wm_hints = XInternAtom(this->display, "_MOTIF_WM_HINTS", False);
-  mwmhints.flags = MWM_HINTS_DECORATIONS;
-  mwmhints.decorations = 0;
-  XChangeProperty(this->display, this->window[1], this->atom_wm_hints, this->atom_wm_hints, 32,
-		  PropModeReplace, (unsigned char *) &mwmhints,
-		  PROP_MWM_HINTS_ELEMENTS);
+  if(this->window_id <= 0) {
+    /* full-screen window */
+    set_fullscreen_props(this);
+
+    /* no border in fullscreen window */
+    this->atom_wm_hints = XInternAtom(this->display, "_MOTIF_WM_HINTS", False);
+    mwmhints.flags = MWM_HINTS_DECORATIONS;
+    mwmhints.decorations = 0;
+    XChangeProperty(this->display, this->window[1], this->atom_wm_hints, this->atom_wm_hints, 32,
+		    PropModeReplace, (unsigned char *) &mwmhints,
+		    PROP_MWM_HINTS_ELEMENTS);
+  }
 
   /* Select input */
@@ -487,10 +512,16 @@
 		ButtonPressMask);
 
-  /* Window name */
-  XStoreName(this->display, this->window[0], "VDR");
-  XStoreName(this->display, this->window[1], "VDR");
 
-  /* Icon */
-  {
+  if(this->window_id <= 0) {
+    /* Window name */
+#ifdef FE_STANDALONE
+    XStoreName(this->display, this->window[0], "VDR - ");
+    XStoreName(this->display, this->window[1], "VDR - ");
+#else
+    XStoreName(this->display, this->window[0], "Local VDR");
+    XStoreName(this->display, this->window[1], "Local VDR");
+#endif
+
+    /* Icon */
     XChangeProperty(this->display, this->window[0],
 		    XInternAtom(this->display, "_NET_WM_ICON", False),
@@ -527,10 +558,6 @@
   XSetWMProtocols(this->display, this->window[fullscreen], &(this->atom_wm_delete_window), 1);
 
-  /* no cursor */
-#if 0
-  XDefineCursor(this->display, this->window[0], None);
-#endif
-  XDefineCursor(this->display, this->window[1], None);
-  {
+  if(this->window_id <= 0) {
+    /* no cursor */
     static char bm_no_data[] = { 0,0,0,0, 0,0,0,0 };
     Pixmap bm_no;
@@ -542,6 +569,8 @@
     no_ptr = XCreatePixmapCursor(this->display, bm_no, bm_no, &black, &black, 0, 0);
 #if 0
+    XDefineCursor(this->display, this->window[0], None);
     XDefineCursor(this->display, this->window[0], no_ptr);
 #endif
+    XDefineCursor(this->display, this->window[1], None);
     XDefineCursor(this->display, this->window[1], no_ptr);
   }
@@ -577,4 +606,22 @@
 }
 
+static int sxfe_display_open_2(frontend_t *this_gen)
+{
+  sxfe_t    *this = (sxfe_t*)this_gen;
+  this->window_id = this_gen->config.window_id;
+
+  return sxfe_display_open(this_gen,
+			   this_gen->config.width,
+			   this_gen->config.height,
+			   this_gen->config.fullscreen,
+			   this_gen->config.modeswitch,
+			   this_gen->config.modeline,
+			   this_gen->config.aspect,
+			   this_gen->config.keypresshandler,
+			   this_gen->config.video_port,
+			   this_gen->config.scale_video,
+			   this_gen->config.field_order);
+}
+
 /*
  * sxfe_display_config
@@ -636,5 +683,5 @@
   }
 
-  if(!modeswitch && strcmp(modeline, this->modeline)) {
+  if(!modeswitch && modeline && strcmp(modeline, this->modeline)) {
     strn0cpy(this->modeline, modeline, sizeof(this->modeline));
     /* #warning TODO - switch vmode */
@@ -885,9 +932,11 @@
       this->fe.xine_exit(this_gen);
     
-    XLockDisplay(this->display);
-    XUnmapWindow(this->display, this->window[this->fullscreen]);
-    XDestroyWindow(this->display, this->window[0]);
-    XDestroyWindow(this->display, this->window[1]);
-    XUnlockDisplay(this->display);
+    if(this->window_id <= 0) {
+      XLockDisplay(this->display);
+      XUnmapWindow(this->display, this->window[this->fullscreen]);
+      XDestroyWindow(this->display, this->window[0]);
+      XDestroyWindow(this->display, this->window[1]);
+      XUnlockDisplay(this->display);
+    }
     XCloseDisplay (this->display);
     this->display = NULL;
@@ -923,4 +972,8 @@
   this->fe.xine_queue_pes_packet = xine_queue_pes_packet;
 #endif /*#ifndef FE_STANDALONE */
+
+  this->fe.fe_display_open_2   = sxfe_display_open_2;
+  //this->fe.fe_display_config_2 = sxfe_display_config_2;
+  this->fe.xine_init_2  = fe_xine_init_2;
   
   return (frontend_t*)this;
