--- xine-lib-1.1.7.org/configure.ac	2007-08-16 11:12:26.000000000 +0000
+++ xine-lib-1.1.7/configure.ac	2007-08-16 11:12:25.000000000 +0000
@@ -2509,6 +2509,28 @@
 
 AM_CONDITIONAL(HAVE_W32DLL, test "x$enable_w32dll" != "xno")
 
+dnl ---------------------------------------------
+dnl let distro override plugin install helper path
+dnl ---------------------------------------------
+AC_ARG_WITH(install-plugins-helper,
+  AC_HELP_STRING([--with-install-plugins-helper],
+    [specify path of helper script to call to install plugins]),
+  [
+    case "${withval}" in
+      yes) AC_MSG_ERROR(bad value ${withval} for --with-install-plugins-helper) ;;
+      no)  AC_MSG_ERROR(bad value ${withval} for --with-install-plugins-helper) ;;
+      *)   XINE_INSTALL_PLUGINS_HELPER="${withval}" ;;
+    esac
+  ],
+  [
+    dnl Default value
+    XINE_INSTALL_PLUGINS_HELPER="`makeexpand "${libexecdir}/xine-install-plugins-helper"`"
+  ]
+)
+AC_MSG_NOTICE(Using $XINE_INSTALL_PLUGINS_HELPER as plugin install helper)
+AC_DEFINE_UNQUOTED(XINE_INSTALL_PLUGINS_HELPER, "$XINE_INSTALL_PLUGINS_HELPER",
+    [plugin install helper script])
+AC_SUBST(XINE_INSTALL_PLUGINS_HELPER)
 
 dnl ---------------------------------------------
 dnl some include paths ( !!! DO NOT REMOVE !!! )
--- xine-lib-1.1.7.org/src/xine-engine/xine.c	2007-08-16 11:12:25.000000000 +0000
+++ xine-lib-1.1.7/src/xine-engine/xine.c	2007-08-16 11:12:21.000000000 +0000
@@ -1643,6 +1643,15 @@
       0, NULL, this);
 
   /*
+   * enable/disable option for the plugins helper
+   */
+  this->config->register_bool(this->config,
+      "media.plugins_helper", 1,
+      _("Run plugins helper"),
+      _("Searches the internet for missing plugins"),
+      0, NULL, this);
+
+  /*
    * keep track of all opened streams
    */
   this->streams = xine_list_new();
--- xine-lib-1.1.7.org/src/xine-engine/video_decoder.c	2007-08-16 11:12:25.000000000 +0000
+++ xine-lib-1.1.7/src/xine-engine/video_decoder.c	2007-08-16 11:40:56.000000000 +0000
@@ -39,6 +39,7 @@
 
 #include "xine_internal.h"
 #include "xineutils.h"
+#include "install_plugins_helper.h"
 #include <sched.h>
 
 #define SPU_SLEEP_INTERVAL (90000/2)
@@ -369,6 +370,10 @@
           stream->video_decoder_plugin = _x_get_video_decoder (stream, streamtype);
     
           _x_stream_info_set(stream, XINE_STREAM_INFO_VIDEO_HANDLED, (stream->video_decoder_plugin != NULL));
+	  if(buf->type != buftype_unknown && !stream->video_decoder_plugin)
+		_x_install_plugins_helper(stream,"decoder-video", buf->type, _x_buf_video_name( buf->type ));	
+
+         
         }
 
         if (stream->video_decoder_plugin)
--- xine-lib-1.1.7.org/src/xine-engine/audio_decoder.c	2007-08-16 11:12:25.000000000 +0000
+++ xine-lib-1.1.7/src/xine-engine/audio_decoder.c	2007-08-16 11:41:24.000000000 +0000
@@ -43,6 +43,7 @@
 
 #include "xine_internal.h"
 #include "xineutils.h"
+#include "install_plugins_helper.h"
 
 static void *audio_decoder_loop (void *stream_gen) {
 
@@ -340,6 +341,10 @@
               
               _x_stream_info_set(stream, XINE_STREAM_INFO_AUDIO_HANDLED,
 				 (stream->audio_decoder_plugin != NULL));
+
+              if(buf->type != buftype_unknown && !stream->audio_decoder_plugin)
+                _x_install_plugins_helper(stream,"decoder-audio", buf->type, _x_buf_audio_name( buf->type ));
+
             }
 	    
 	    if (audio_type != stream->audio_type) {
--- xine-lib-1.1.7.org/src/xine-engine/Makefile.am	2007-08-16 11:12:25.000000000 +0000
+++ xine-lib-1.1.7/src/xine-engine/Makefile.am	2007-08-16 11:12:21.000000000 +0000
@@ -19,7 +19,7 @@
 	video_overlay.c osd.c scratch.c demux.c vo_scale.c \
 	xine_interface.c post.c tvmode.c broadcaster.c io_helper.c \
 	input_rip.c input_cache.c info_helper.c refcounter.c \
-	alphablend.c
+	alphablend.c install_plugins_helper.c
 
 # FIXME: these are currently unused:
 EXTRA_DIST = lrb.c lrb.h accel_xvmc.h
@@ -39,7 +39,8 @@
         audio_out.h resample.h video_out.h xine_internal.h spu_decoder.h \
 	video_overlay.h osd.h scratch.h xine_plugin.h xineintl.h  \
 	plugin_catalog.h audio_decoder.h video_decoder.h post.h \
-	io_helper.h broadcaster.h info_helper.h refcounter.h alphablend.h
+	io_helper.h broadcaster.h info_helper.h refcounter.h alphablend.h \
+        install_plugins_helper.h
 
 noinst_HEADERS = bswap.h ffmpeg_bswap.h
 
--- /dev/null	2007-08-16 10:48:37.000000000 +0000
+++ xine-lib-1.1.7/src/xine-engine/install_plugins_helper.h	2007-08-16 11:12:21.000000000 +0000
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2007 Sascha Sommer 
+ *
+ * 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
+ *
+ * helper functions to query the internet for additional codecs
+ */
+
+#ifndef PLUGINS_HELPER_H
+#define PLUGINS_HELPER_H
+
+#include <inttypes.h>
+#include "xine_internal.h"
+
+/*
+ * execute install plugins helper 
+ */
+void _x_install_plugins_helper(xine_stream_t *stream, char* plugin_type, uint32_t type, char* plugin_desc) XINE_PROTECTED;
+
+
+#endif
--- /dev/null	2007-03-17 21:04:06.000000000 +0100
+++ xine-lib-1.1.7/src/xine-engine/install_plugins_helper.c	2007-08-18 14:11:15.000000000 +0200
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2007 Sascha Sommer
+ *
+ * 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
+ *
+ * helper functions to query the internet for additional plugins
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#include "install_plugins_helper.h"
+
+#define PROCNAME_LEN  100
+
+static const char *
+get_helper(xine_stream_t *stream)
+{
+  const char *helper;
+
+  helper = getenv("XINE_INSTALL_PLUGINS_HELPER");
+  if (helper == NULL)
+    helper = XINE_INSTALL_PLUGINS_HELPER;
+
+  xine_log (stream->xine, XINE_LOG_MSG,
+                    _("Using plugin install helper '%s'"), helper);
+
+  return helper;
+}
+
+static void
+get_procname(char* procname, size_t len)
+{
+  char name[100];
+  FILE* fp;
+  size_t pos = 0;
+  snprintf(name, sizeof(name), "/proc/%u/cmdline", getpid());
+
+  fp = fopen(name,"rb");
+  if(fp){
+    while(fp && !feof(fp) && pos < sizeof(name)-1){
+      procname[pos] = fgetc(fp);
+      if(procname[pos] == ' ') /* ignore arguments */
+        break;
+      if(procname[pos] == '/') /* ignore the path to the executable */
+        pos = 0;
+      else
+        ++pos;
+    }
+    fclose(fp);
+  }
+  procname[pos] = '\0';
+}
+
+
+void _x_install_plugins_helper(xine_stream_t* stream,char* plugin_type, uint32_t id, char* plugin_desc)
+{
+  xine_cfg_entry_t cfgentry;
+  char* helper = get_helper(stream);
+  FILE* fp;
+
+  if(helper && xine_config_lookup_entry(stream->xine, "media.plugins_helper", &cfgentry) && cfgentry.num_value 
+       && (fp = fopen(helper,"rb") )) {
+        char procname[PROCNAME_LEN];
+//	char* procname = getenv("_"); /* might deliver /opt/kde3/bin/start_kdeinit_wrapper etc... */
+  	pid_t pid;
+        fclose(fp);
+        get_procname(procname,PROCNAME_LEN);
+        pid  = fork();
+        if(pid == 0) {
+	  size_t len = 5 + strlen(XINE_VERSION) + 1 + strlen(procname) + 1 + strlen(plugin_desc) + 1 + strlen(plugin_type) + 1 + 100 + 1;
+	  char* str = calloc(1,len + 1);
+	  if(str){
+            snprintf(str,len,"xine|%s|%s|%s|%s=%u",XINE_VERSION,procname,plugin_desc,plugin_type,id);
+            if(execl(helper,"xine-install-plugins-helper",str, NULL) == -1)
+              xine_log(stream->xine, XINE_LOG_MSG,
+                    _("Couldn't start plugins_helper"));
+	    free(str);
+          }
+        }else if(pid < 0){
+          xine_log(stream->xine, XINE_LOG_MSG,
+                    _("Couldn't fork"));
+	}else{
+          waitpid(pid, NULL, 0);
+        }
+  } 
+}
+