Author: tack
Date: Thu Nov 30 22:54:18 2006
New Revision: 2139
Modified:
trunk/popcorn/src/backends/mplayer/__init__.py
trunk/popcorn/src/backends/mplayer/config.cxml
trunk/popcorn/src/backends/mplayer/player.py
Log:
Make mplayer info gathering about 2-2.5X faster; add config variable for
mplayer path.
Modified: trunk/popcorn/src/backends/mplayer/__init__.py
==============================================================================
--- trunk/popcorn/src/backends/mplayer/__init__.py (original)
+++ trunk/popcorn/src/backends/mplayer/__init__.py Thu Nov 30 22:54:18 2006
@@ -3,10 +3,13 @@
from player import MPlayer, _get_mplayer_info
from kaa.popcorn.backends import register
from kaa.popcorn.ptypes import *
+from config import config
def get_capabilities():
capabilities = [CAP_VIDEO, CAP_AUDIO, CAP_DVD, CAP_VARIABLE_SPEED]
- mp_cmd = kaa.utils.which("mplayer")
+ mp_cmd = config.path
+ if not mp_cmd:
+ mp_cmd = kaa.utils.which("mplayer")
info = _get_mplayer_info(mp_cmd)
if not info:
return None, None, None
Modified: trunk/popcorn/src/backends/mplayer/config.cxml
==============================================================================
--- trunk/popcorn/src/backends/mplayer/config.cxml (original)
+++ trunk/popcorn/src/backends/mplayer/config.cxml Thu Nov 30 22:54:18 2006
@@ -4,4 +4,7 @@
<var name="activate" default="True">
<desc lang="en">activate backend</desc>
</var>
+ <var name="path" type="str">
+ <desc lang="en">Path to mplayer binary (if empty, search $PATH)</desc>
+ </var>
</config>
Modified: trunk/popcorn/src/backends/mplayer/player.py
==============================================================================
--- trunk/popcorn/src/backends/mplayer/player.py (original)
+++ trunk/popcorn/src/backends/mplayer/player.py Thu Nov 30 22:54:18 2006
@@ -99,7 +99,6 @@
return None
# At this point we're running in a thread.
-
info = {
"version": None,
"mtime": mtime,
@@ -110,30 +109,45 @@
"keylist": []
}
- regexps = (
- ("video_filters", "-vf help", "\s*(\w+)\s+:\s+(.*)"),
- ("video_drivers", "-vo help", "\s*(\w+)\s+(.*)"),
- ("audio_filters", "-af help", "\s*(\w+)\s+:\s+(.*)"),
- ("audio_drivers", "-ao help", "\s*(\w+)\s+(.*)"),
- ("keylist", "-input keylist", "^(\w+)$"),
- )
-
- for key, args, regexp in regexps:
- for line in os.popen("%s %s" % (path, args)):
- # Check version
- if line.startswith("MPlayer "):
- info["version"] = line.split()[1]
-
- # Check regexp
- m = re.match(regexp, line.strip())
- if not m:
- continue
+ groups = {
+ 'video_filters': ('Available video filters', r'\s*(\w+)\s+:\s+(.*)'),
+ 'video_drivers': ('Available video output', r'\s*(\w+)\s+(.*)'),
+ 'audio_filters': ('Available audio filters', r'\s*(\w+)\s+:\s+(.*)'),
+ 'audio_drivers': ('Available audio output', r'\s*(\w+)\s+(.*)')
+ }
+ curgroup = None
+ for line in os.popen('%s -vf help -af help -vo help -ao help' % path):
+ # Check version
+ if line.startswith("MPlayer "):
+ info['version'] = line.split()[1]
+ # Find current group.
+ for group, (header, regexp) in groups.items():
+ if line.startswith(header):
+ curgroup = group
+ break
+ if not curgroup:
+ continue
+
+ # Check regexp
+ m = re.match(groups[curgroup][1], line.strip())
+ if not m:
+ continue
+
+ if len(m.groups()) == 2:
+ info[curgroup][m.group(1)] = m.group(2)
+ else:
+ info[curgroup].append(m.group(1))
+
+ # Another pass for key list.
+ for line in os.popen('%s -input keylist' % path):
+ # Check regexp
+ m = re.match(r'^(\w+)$', line.strip())
+ if not m:
+ continue
+ info['keylist'].append(m.group(1))
- if len(m.groups()) == 2:
- info[key][m.group(1)] = m.group(2)
- else:
- info[key].append(m.group(1))
+ print len(info['video_filters'])
_cache[path] = info
return info
@@ -141,14 +155,13 @@
class MPlayer(MediaPlayer):
- PATH = None
RE_STATUS = re.compile("V:\s*([\d+\.]+)|A:\s*([\d+\.]+)\s\W")
RE_SWS = re.compile("^SwScaler: [0-9]+x[0-9]+ -> ([0-9]+)x([0-9]+)")
def __init__(self):
super(MPlayer, self).__init__()
self._state = STATE_NOT_RUNNING
- self._mp_cmd = MPlayer.PATH
+ self._mp_cmd = self._config.path
if not self._mp_cmd:
self._mp_cmd = kaa.utils.which("mplayer")
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog