Update of /cvsroot/freevo/freevo/src/video/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv15838

Modified Files:
        mplayer.py xine.py 
Log Message:
cleanup

Index: mplayer.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/plugins/mplayer.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** mplayer.py  1 Jan 2004 19:37:31 -0000       1.55
--- mplayer.py  2 Jan 2004 11:17:35 -0000       1.56
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.56  2004/01/02 11:17:35  dischi
+ # cleanup
+ #
  # Revision 1.55  2004/01/01 19:37:31  dischi
  # dvd and interlace fixes
***************
*** 33,73 ****
  # move to new ChildApp2 and remove the internal thread
  #
- # Revision 1.48  2003/12/09 20:40:13  dischi
- # fixed copy paste error
- #
- # Revision 1.47  2003/12/09 19:43:22  dischi
- # subtitle file and audio file support
- #
- # Revision 1.46  2003/12/07 19:40:30  dischi
- # convert OVERSCAN variable names
- #
- # Revision 1.45  2003/12/06 16:25:45  dischi
- # support for type=url and <playlist> and <player>
- #
- # Revision 1.44  2003/11/29 18:37:30  dischi
- # build config.VIDEO_SUFFIX in config on startup
- #
- # Revision 1.43  2003/11/28 20:08:59  dischi
- # renamed some config variables
- #
- # Revision 1.42  2003/11/28 19:26:37  dischi
- # renamed some config variables
- #
- # Revision 1.41  2003/11/22 15:57:47  dischi
- # cleanup
- #
- # Revision 1.40  2003/11/21 18:04:27  dischi
- # remove debug
- #
- # Revision 1.39  2003/11/21 17:56:50  dischi
- # Plugins now 'rate' if and how good they can play an item. Based on that
- # a good player will be choosen.
- #
- # Revision 1.38  2003/11/04 17:53:23  dischi
- # Removed the unstable bmovl part from mplayer.py and made it a plugin.
- # Even if we are in a code freeze, this is a major cleanup to put the
- # unstable stuff in a plugin to prevent mplayer from crashing because of
- # bmovl.
- #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
--- 36,39 ----
***************
*** 93,99 ****
  
  
! import time, os, re
! import threading, signal
! import traceback, popen2
  
  import config     # Configuration handler. reads config file.
--- 59,65 ----
  
  
! import os, re
! import threading
! import popen2
  
  import config     # Configuration handler. reads config file.
***************
*** 101,107 ****
  import childapp   # Handle child applications
  import rc         # The RemoteControl class.
  
  from event import *
- import plugin
  
  
--- 67,73 ----
  import childapp   # Handle child applications
  import rc         # The RemoteControl class.
+ import plugin
  
  from event import *
  
  
***************
*** 115,121 ****
      def __init__(self):
          mplayer_version = 0
-         # create the mplayer object
-         plugin.Plugin.__init__(self)
  
          if not hasattr(config, 'MPLAYER_VERSION'):
              child = popen2.Popen3( "%s -v" % config.MPLAYER_CMD, 1, 100)
--- 81,87 ----
      def __init__(self):
          mplayer_version = 0
  
+         # Detect version of mplayer. Possible values are
+         # 0.9 (for 0.9.x series), 1.0 (for 1.0preX series) and 9999 for cvs
          if not hasattr(config, 'MPLAYER_VERSION'):
              child = popen2.Popen3( "%s -v" % config.MPLAYER_CMD, 1, 100)
***************
*** 137,144 ****
--- 103,120 ----
              child.wait()
  
+         if not config.MPLAYER_VERSION:
+             self.reason = 'failed to detect mplayer version'
+             return
+         
+         # create plugin structure
+         plugin.Plugin.__init__(self)
+ 
          # register mplayer as the object to play video
          plugin.register(MPlayer(config.MPLAYER_VERSION), plugin.VIDEO_PLAYER, True)
  
  
+ 
+ 
+ 
  class MPlayer:
      """
***************
*** 146,157 ****
      """
      def __init__(self, version):
!         self.name = 'mplayer'
  
!         self.mode = None
!         self.app_mode = 'video'
!         self.version = version
!         self.seek = 0
          self.seek_timer = threading.Timer(0, self.reset_seek)
!         self.app = None
  
  
--- 122,135 ----
      """
      def __init__(self, version):
!         """
!         init the mplayer object
!         """
!         self.name       = 'mplayer'
  
!         self.app_mode   = 'video'
!         self.version    = version
!         self.seek       = 0
          self.seek_timer = threading.Timer(0, self.reset_seek)
!         self.app        = None
  
  
***************
*** 178,187 ****
          play a videoitem with mplayer
          """
!         self.parameter = (options, item)
          
          mode         = item.mode
-         network_play = item.network_play
          url          = item.url
-         self.item    = item
  
          if mode == 'file':
--- 156,164 ----
          play a videoitem with mplayer
          """
!         self.options = options
!         self.item    = item
          
          mode         = item.mode
          url          = item.url
  
          if mode == 'file':
***************
*** 210,216 ****
  
          # Build the MPlayer command
!         mpl = [ '--prio=%s' % config.MPLAYER_NICE, config.MPLAYER_CMD ]
!         mpl += config.MPLAYER_ARGS_DEF.split(' ')
!         mpl += [ '-slave', '-ao', config.MPLAYER_AO_DEV ]
  
          additional_args = []
--- 187,193 ----
  
          # Build the MPlayer command
!         command = [ '--prio=%s' % config.MPLAYER_NICE, config.MPLAYER_CMD ] + \
!                   config.MPLAYER_ARGS_DEF.split(' ') + \
!                   [ '-slave', '-ao', config.MPLAYER_AO_DEV ]
  
          additional_args = []
***************
*** 261,294 ****
  
          # Mplayer command and standard arguments
!         mpl += [ '-v', '-vo', config.MPLAYER_VO_DEV +
!                  config.MPLAYER_VO_DEV_OPTS ]
!         mpl += config.MPLAYER_ARGS[mode].split(' ')
  
          # make the options a list
!         mpl += additional_args
  
          if hasattr(item, 'is_playlist') and item.is_playlist:
!             mpl.append('-playlist')
  
          # add the file to play
!         mpl.append(url)
  
          if options:
!             mpl += options
  
          # use software scaler?
!         if '-nosws' in mpl:
!             mpl.remove('-nosws')
  
!         elif not '-framedrop' in mpl:
!             mpl += config.MPLAYER_SOFTWARE_SCALER.split(' ')
  
          # correct avi delay based on mmpython settings
          if config.MPLAYER_SET_AUDIO_DELAY and item.info.has_key('delay') and \
                 item.info['delay'] > 0:
!             mpl += [ '-mc', str(int(item.info['delay'])+1), '-delay',
!                     '-' + str(item.info['delay']) ]
! 
!         command = mpl
  
          while '' in command:
--- 238,271 ----
  
          # Mplayer command and standard arguments
!         command += [ '-v', '-vo', config.MPLAYER_VO_DEV +
!                      config.MPLAYER_VO_DEV_OPTS ]
! 
!         # mode specific args
!         command += config.MPLAYER_ARGS[mode].split(' ')
  
          # make the options a list
!         command += additional_args
  
          if hasattr(item, 'is_playlist') and item.is_playlist:
!             command.append('-playlist')
  
          # add the file to play
!         command.append(url)
  
          if options:
!             command += options
  
          # use software scaler?
!         if '-nosws' in command:
!             command.remove('-nosws')
  
!         elif not '-framedrop' in command:
!             command += config.MPLAYER_SOFTWARE_SCALER.split(' ')
  
          # correct avi delay based on mmpython settings
          if config.MPLAYER_SET_AUDIO_DELAY and item.info.has_key('delay') and \
                 item.info['delay'] > 0:
!             command += [ '-mc', str(int(item.info['delay'])+1), '-delay',
!                          '-' + str(item.info['delay']) ]
  
          while '' in command:
***************
*** 301,305 ****
              crop_cmd = command[1:] + ['-ao', 'null', '-vo', 'null', '-ss', '60',
                                        '-frames', '20', '-vop', 'cropdetect' ]
!             child = popen2.Popen3(self.vop_append(crop_cmd), 1, 100)
              exp = re.compile('^.*-vop crop=([0-9]*):([0-9]*):([0-9]*):([0-9]*).*')
              while(1):
--- 278,282 ----
              crop_cmd = command[1:] + ['-ao', 'null', '-vo', 'null', '-ss', '60',
                                        '-frames', '20', '-vop', 'cropdetect' ]
!             child = popen2.Popen3(self.sort_filter(crop_cmd), 1, 100)
              exp = re.compile('^.*-vop crop=([0-9]*):([0-9]*):([0-9]*):([0-9]*).*')
              while(1):
***************
*** 334,338 ****
              command = p.play(command, self)
  
!         command=self.vop_append(command)
  
          if plugin.getbyname('MIXER'):
--- 311,315 ----
              command = p.play(command, self)
  
!         command=self.sort_filter(command)
  
          if plugin.getbyname('MIXER'):
***************
*** 341,345 ****
          rc.app(self)
  
!         self.app = MPlayerApp(command, self, item, network_play)
          return None
      
--- 318,322 ----
          rc.app(self)
  
!         self.app = MPlayerApp(command, self)
          return None
      
***************
*** 347,352 ****
      def stop(self):
          """
!         Stop mplayer and set thread to idle
          """
          self.app.stop('quit\n')
          rc.app(None)
--- 324,332 ----
      def stop(self):
          """
!         Stop mplayer
          """
+         if not self.app:
+             return
+         
          self.app.stop('quit\n')
          rc.app(None)
***************
*** 362,365 ****
--- 342,347 ----
          function it will be passed over to the items eventhandler
          """
+         if not self.app:
+             return self.item.eventhandler(event)
  
          for p in self.plugins:
***************
*** 400,404 ****
          if event == 'AUDIO_ERROR_START_AGAIN':
              self.stop()
!             self.play(self.parameter[0], self.parameter[1])
              return True
          
--- 382,386 ----
          if event == 'AUDIO_ERROR_START_AGAIN':
              self.stop()
!             self.play(self.options, self.item)
              return True
          
***************
*** 407,436 ****
              return self.item.eventhandler(event)
  
!         try:
!             if event == VIDEO_SEND_MPLAYER_CMD:
!                 self.app.write('%s\n' % event.arg)
!                 return True
! 
!             if event == TOGGLE_OSD:
!                 self.app.write('osd\n')
!                 return True
  
!             if event == PAUSE or event == PLAY:
!                 self.app.write('pause\n')
!                 return True
  
!             if event == SEEK:
!                 self.app.write('seek %s\n' % event.arg)
!                 return True
  
!             if event == OSD_MESSAGE:
!                 self.app.write('osd_show_text "%s"\n' % event.arg);
!                 return TRUE
  
!         except:
!             print 'Exception while sending command to mplayer:'
!             traceback.print_exc()
              return True
!         
          # nothing found? Try the eventhandler of the object who called us
          return self.item.eventhandler(event)
--- 389,412 ----
              return self.item.eventhandler(event)
  
!         if event == VIDEO_SEND_MPLAYER_CMD:
!             self.app.write('%s\n' % event.arg)
!             return True
  
!         if event == TOGGLE_OSD:
!             self.app.write('osd\n')
!             return True
  
!         if event == PAUSE or event == PLAY:
!             self.app.write('pause\n')
!             return True
  
!         if event == SEEK:
!             self.app.write('seek %s\n' % event.arg)
!             return True
  
!         if event == OSD_MESSAGE:
!             self.app.write('osd_show_text "%s"\n' % event.arg);
              return True
! 
          # nothing found? Try the eventhandler of the object who called us
          return self.item.eventhandler(event)
***************
*** 449,453 ****
  
          
!     def vop_append(self, command):
          """
          Change a mplayer command to support more than one -vop
--- 425,429 ----
  
          
!     def sort_filter(self, command):
          """
          Change a mplayer command to support more than one -vop
***************
*** 484,507 ****
      """
  
!     def __init__(self, app, mplayer, item, network_play):
          # DVD items also store mplayer_audio_broken to check if you can
          # start them with -alang or not
!         if hasattr(item, 'mplayer_audio_broken') or item.mode != 'dvd':
              self.check_audio = 0
          else:
              self.check_audio = 1
  
!         self.network_play = network_play
!         self.RE_TIME      = re.compile("^A: *([0-9]+)").match
!         self.RE_START     = re.compile("^Starting playback\.\.\.").match
!         self.RE_EXIT      = re.compile("^Exiting\.\.\. \((.*)\)$").match
!         self.item         = item
!         self.mplayer      = mplayer
!         self.exit_type    = None
! 
!         import osd
!         self.osd          = osd.get_singleton()
!         self.osdfont      = self.osd.getfont(config.OSD_DEFAULT_FONTNAME,
!                                              config.OSD_DEFAULT_FONTSIZE)
  
          # check for mplayer plugins
--- 460,482 ----
      """
  
!     def __init__(self, app, mplayer):
!         self.RE_TIME   = re.compile("^A: *([0-9]+)").match
!         self.RE_START  = re.compile("^Starting playback\.\.\.").match
!         self.RE_EXIT   = re.compile("^Exiting\.\.\. \((.*)\)$").match
!         self.item      = mplayer.item
!         self.mplayer   = mplayer
!         self.exit_type = None
!                        
          # DVD items also store mplayer_audio_broken to check if you can
          # start them with -alang or not
!         if hasattr(self.item, 'mplayer_audio_broken') or self.item.mode != 'dvd':
              self.check_audio = 0
          else:
              self.check_audio = 1
  
!         import osd     
!         self.osd       = osd.get_singleton()
!         self.osdfont   = self.osd.getfont(config.OSD_DEFAULT_FONTNAME,
!                                           config.OSD_DEFAULT_FONTSIZE)
  
          # check for mplayer plugins
***************
*** 520,523 ****
--- 495,501 ----
                  
      def stop_event(self):
+         """
+         return the stop event send through the eventhandler
+         """
          if self.exit_type == "End of file":
              return PLAY_END
***************
*** 525,529 ****
              return USER_END
          else:
!             print _( 'ERROR' ) + ': ' + _( 'unknow error while playing file' )
              return PLAY_END
                          
--- 503,508 ----
              return USER_END
          else:
!             print _( 'ERROR' ) + ': ' + self.exit_type + \
!                   _( 'unknow error while playing file' )
              return PLAY_END
                          
***************
*** 534,551 ****
          """
          # show connection status for network play
!         if self.network_play:
              if line.find('Opening audio decoder') == 0:
                  self.osd.clearscreen(self.osd.COL_BLACK)
                  self.osd.update()
!             elif (line.find('Resolving ') == 0 or line.find('Connecting to server') 
== 0 or \
!                   line.find('Cache fill:') == 0) and \
                    line.find('Resolving reference to') == -1:
!                 if line.find('Connecting to server') == 0:
                      line = 'Connecting to server'
                  self.osd.clearscreen(self.osd.COL_BLACK)
                  self.osd.drawstringframed(line, config.OSD_OVERSCAN_X+10,
                                            config.OSD_OVERSCAN_Y+10,
!                                           self.osd.width - 2 * 
(config.OSD_OVERSCAN_X+10), -1,
!                                           self.osdfont, self.osd.COL_WHITE)
                  self.osd.update()
  
--- 513,532 ----
          """
          # show connection status for network play
!         if self.item.network_play:
              if line.find('Opening audio decoder') == 0:
                  self.osd.clearscreen(self.osd.COL_BLACK)
                  self.osd.update()
!             elif (line.startswith('Resolving ') or \
!                   line.startswith('Connecting to server') or \
!                   line.startswith('Cache fill:')) and \
                    line.find('Resolving reference to') == -1:
! 
!                 if line.startswith('Connecting to server'):
                      line = 'Connecting to server'
                  self.osd.clearscreen(self.osd.COL_BLACK)
                  self.osd.drawstringframed(line, config.OSD_OVERSCAN_X+10,
                                            config.OSD_OVERSCAN_Y+10,
!                                           self.osd.width - 2 * 
(config.OSD_OVERSCAN_X+10),
!                                           -1, self.osdfont, self.osd.COL_WHITE)
                  self.osd.update()
  

Index: xine.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/video/plugins/xine.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** xine.py     29 Dec 2003 22:08:55 -0000      1.33
--- xine.py     2 Jan 2004 11:17:35 -0000       1.34
***************
*** 18,21 ****
--- 18,24 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.34  2004/01/02 11:17:35  dischi
+ # cleanup
+ #
  # Revision 1.33  2003/12/29 22:08:55  dischi
  # move to new Item attributes
***************
*** 62,66 ****
  import childapp   # Handle child applications
  import rc         # The RemoteControl class.
! import util.popen3
  
  from event import *
--- 65,69 ----
  import childapp   # Handle child applications
  import rc         # The RemoteControl class.
! import util
  
  from event import *
***************
*** 102,114 ****
              
          if config.XINE_VERSION < 922:
!             if type == 'fb':
!                 print _( 'ERROR' ) + ': ' + \
!                       _( "'fbxine' version too old, plugin 'xine' deactivated" )
!                 print _( 'You need software %s' ) % 'xine-ui > 0.9.21'
!                 return
!             print _( 'WARNING' ) + ': ' + \
!                   _( "'xine' version too old, plugin in fallback mode" )
!             print _( "You need %s to use all features of the '%s' plugin" ) % \
!                   ( 'xine-ui > 0.9.21', 'xine' )
              
          # register xine as the object to play
--- 105,112 ----
              
          if config.XINE_VERSION < 922:
!             print _( 'ERROR' ) + ': ' + \
!                   _( "'xine-ui' version too old, plugin 'xine' deactivated" )
!             print _( 'You need software %s' ) % 'xine-ui > 0.9.21'
!             return
              
          # register xine as the object to play
***************
*** 121,137 ****
      the main class to control xine
      """
-     
      def __init__(self, type, version):
!         self.name = 'xine'
  
!         self.mode         = None
!         self.app_mode     = ''
!         self.xine_type    = type
!         self.xine_version = version
!         self.app          = None
  
          self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
                         config.XINE_COMMAND.split(' ') + \
!                        [ '--stdctl', '-V', config.XINE_VO_DEV, '-A', 
config.XINE_AO_DEV ] +\
                         config.XINE_ARGS_DEF.split(' ')
  
--- 119,134 ----
      the main class to control xine
      """
      def __init__(self, type, version):
!         self.name      = 'xine'
  
!         self.app_mode  = ''
!         self.xine_type = type
!         self.version   = version
!         self.app       = None
  
          self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
                         config.XINE_COMMAND.split(' ') + \
!                        [ '--stdctl', '-V', config.XINE_VO_DEV,
!                          '-A', config.XINE_AO_DEV ] + \
                         config.XINE_ARGS_DEF.split(' ')
  
***************
*** 147,151 ****
              return 2
          if item.url.startswith('vcd://'):
!             if self.xine_version > 922 and item.url == 'vcd://':
                  return 2
              return 0
--- 144,148 ----
              return 2
          if item.url.startswith('vcd://'):
!             if self.version > 922 and item.url == 'vcd://':
                  return 2
              return 0
***************
*** 164,167 ****
--- 161,165 ----
          self.item     = item
          self.app_mode = item.mode
+ 
          if item.mode in ('file', 'url'):
               self.app_mode = 'video'
***************
*** 172,176 ****
          command = copy.copy(self.command)
  
!         if item.deinterlace and (self.xine_type == 'X' or self.xine_version > 922):
              command.append('-D')
  
--- 170,174 ----
          command = copy.copy(self.command)
  
!         if item.deinterlace and (self.xine_type == 'X' or self.version > 922):
              command.append('-D')
  
***************
*** 178,182 ****
              command.remove('--no-lirc')
  
!         if self.xine_version < 922:
              for arg in command:
                  if arg.startswith('--post'):
--- 176,180 ----
              command.remove('--no-lirc')
  
!         if self.version < 923:
              for arg in command:
                  if arg.startswith('--post'):
***************
*** 189,193 ****
          self.current_subtitle = -1
  
!         if item.mode == 'dvd' and item.url == 'dvd://':
              for track in item.info['tracks']:
                  self.max_audio = max(self.max_audio, len(track['audio']))
--- 187,191 ----
          self.current_subtitle = -1
  
!         if item.url == 'dvd://':
              for track in item.info['tracks']:
                  self.max_audio = max(self.max_audio, len(track['audio']))
***************
*** 198,206 ****
          if item.mode == 'dvd':
              # dvd:///dev/dvd/2
!             if not item.filename or item.filename == '0':
!                 track = ''
!             else:
!                 track = item.filename
!             command.append('dvd://%s/%s' % (item.media.devicename, track))
  
          elif item.mode == 'vcd':
--- 196,200 ----
          if item.mode == 'dvd':
              # dvd:///dev/dvd/2
!             command.append('dvd://%s/%s' % (item.media.devicename, item.url[6:]))
  
          elif item.mode == 'vcd':
***************
*** 226,231 ****
          Stop xine
          """
!         self.app.stop('quit\n')
!         rc.app(None)
              
  
--- 220,226 ----
          Stop xine
          """
!         if self.app:
!             self.app.stop('quit\n')
!             rc.app(None)
              
  
***************
*** 235,246 ****
          function it will be passed over to the items eventhandler
          """
          if event in ( PLAY_END, USER_END ):
              self.stop()
              return self.item.eventhandler(event)
  
-         # fallback for older versions of xine
-         if self.xine_version < 922:
-             return True
-         
          if event == PAUSE or event == PLAY:
              self.app.write('pause\n')
--- 230,240 ----
          function it will be passed over to the items eventhandler
          """
+         if not self.app:
+             return self.item.eventhandler(event)
+             
          if event in ( PLAY_END, USER_END ):
              self.stop()
              return self.item.eventhandler(event)
  
          if event == PAUSE or event == PLAY:
              self.app.write('pause\n')




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to