[MPlayer-dev-eng] [PATCH] config per media file

Magne Oestlyngen ml at skybert.org
Tue Dec 3 16:09:33 CET 2002


[this is a resend.  Moderator, please ignore old one (sent before
 I joined the list).]

Hi,

Often, you have to give different options to different input files.
Some need to select right stream, others need cropping.

So here is a patch making that easier.

The patch adds support for a per-file config, which is loaded before
playing the file.  The config file is looked for in the same directory
as the input file, and in the ~/.mplayer dir.

The config file should be named <file>.conf, eg. if the input file
is named "movie.mpeg", the corresponding config file is
"movie.mpeg.conf".

The patch is against todays MPlayer-current.tar.bz2 (Dec 1.)

-- 
Magne Oestlyngen

-------------- next part --------------
--- MPlayer-20021201/mplayer.c	2002-12-02 01:04:15.000000000 +0100
+++ MPlayer-20021201/mplayer.c.new	2002-12-02 01:05:27.000000000 +0100
@@ -504,6 +504,42 @@
 }
 }
 
+void load_per_file_config (m_config_t* conf, const char *const file)
+{
+    char *confpath;
+    char cfg[PATH_MAX];
+    struct stat st;
+    char *name;
+
+    sprintf (cfg, "%s.conf", file);
+    
+    if (!stat (cfg, &st))
+    {
+	mp_msg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", cfg);
+	m_config_parse_config_file (conf, cfg);
+	return;
+    }
+
+    if ((name = strrchr (cfg, '/')) == NULL){
+	name = cfg;
+    }
+    else
+    {
+	name++;
+    }
+
+    if ((confpath = get_path (name)) != NULL)
+    {
+	if (!stat (confpath, &st))
+	{
+	    mp_msg(MSGT_CPLAYER,MSGL_INFO,"Loading config '%s'\n", confpath);
+	    m_config_parse_config_file (conf, confpath);
+	}
+
+	free (confpath);
+    }
+}
+
 // When libmpdemux perform a blocking operation (network connection or cache filling)
 // if the operation fail we use this function to check if it was interrupted by the user.
 // The function return a new value for eof.
@@ -852,6 +888,11 @@
 
 play_next_file:
 
+  if (filename)
+  {
+      load_per_file_config (mconfig, filename);
+  }
+  
 // We must enable getch2 here to be able to interrupt network connection
 // or cache filling
 if(!use_stdin && !slave_mode){


More information about the MPlayer-dev-eng mailing list