Author: tack
Date: Thu Nov 30 04:57:56 2006
New Revision: 2128

Modified:
   trunk/popcorn/src/backends/manager.py
   trunk/popcorn/src/backends/xine/child.py
   trunk/popcorn/src/backends/xine/player.py
   trunk/popcorn/src/generic.py
   trunk/popcorn/src/utils/ipc.py

Log:
Add debugging to ipc; add set_window() api to generic player and allow window
to be set dynamically in xine backend; add some FIXMEs to the state stuff --
it has some issues; fix bug in set_frame_output_mode not passing arguments to
underlying player; fix player selection algorithm to prefer player with
CAP_DVD_MENUS if scheme is dvd:// even over the configured preferred player;
slight refactoring of configuration in xine backend.


Modified: trunk/popcorn/src/backends/manager.py
==============================================================================
--- trunk/popcorn/src/backends/manager.py       (original)
+++ trunk/popcorn/src/backends/manager.py       Thu Nov 30 04:57:56 2006
@@ -122,25 +122,25 @@
     choice = None
     for player_id, player in _players.items():
         if mrl != None and scheme not in player["schemes"]:
-            # mrl scheme not supported by this player
+            # MRL scheme is not supported by this player.
             continue
         if exclude and player_id in exclude:
+            # Player is in exclude list.
             continue
-        if caps != None:
-            if not sets.Set(caps).issubset(sets.Set(player["caps"])):
-                # Requested capabilities not present.
-                continue
-            if scheme == "dvd" and choice and \
-                   CAP_DVD_MENUS in choice["caps"] and \
-                   CAP_DVD_MENUS not in player["caps"]:
-                # If the mrl is dvd, make sure we prefer the player that
-                # supports CAP_DVD_MENUS
-                continue
-        if mrl and choice and ext in choice["extensions"] and \
-           ext not in player["extensions"]:
+        if caps != None and not 
sets.Set(caps).issubset(sets.Set(player["caps"])):
+            # Requested capabilities not present.
+            continue
+        if mrl and choice and ext in choice["extensions"] and ext not in 
player["extensions"]:
+            # Our current choice lists the mrl's extension while this choice 
+            # doesn't.
             continue
 
-        if player_id == preferred or not choice:
+        if scheme == 'dvd' and choice and CAP_DVD_MENUS in player["caps"] and \
+           CAP_DVD_MENUS not in choice["caps"]:
+            # If the mrl is dvd, make sure we prefer the player that supports
+            # CAP_DVD_MENUS
+            choice = player
+        elif player_id == preferred or not choice:
             choice = player
 
     if not choice:

Modified: trunk/popcorn/src/backends/xine/child.py
==============================================================================
--- trunk/popcorn/src/backends/xine/child.py    (original)
+++ trunk/popcorn/src/backends/xine/child.py    Thu Nov 30 04:57:56 2006
@@ -183,7 +183,7 @@
         return self._osd_shmem.addr + 16, width * 4, self._frame_shmem.addr
 
 
-    def handle_xine_event(self, event):
+    def _handle_xine_event(self, event):
         """
         Received event from xine.
         """
@@ -201,16 +201,27 @@
         self.parent.xine_event(event.type, event.data)
 
 
+    def _wire_ao_driver(self, ao):
+        if self._stream:
+            self._stream.get_audio_source().wire(self._ao)
+        
+    
+    def _wire_vo_driver(self, vo):
+        if self._stream:
+            
self._stream.get_video_source().wire(self._deint_post.get_default_input())
+
     # 
#############################################################################
     # Commands from parent process
     # 
#############################################################################
 
     def window_changed(self, wid, size, visible, exposed_regions):
-        self._x11_window_size = size
         if not self._vo:
             return
         # FIXME: what happens if this is no X11 window?
-        self._vo.send_gui_data(xine.GUI_SEND_VIDEOWIN_VISIBLE, visible)
+        if size is not None:
+            self._x11_window_size = size
+        if visible is not None:
+            self._vo.send_gui_data(xine.GUI_SEND_VIDEOWIN_VISIBLE, visible)
         self._vo.send_gui_data(xine.GUI_SEND_DRAWABLE_CHANGED, wid)
 
 
@@ -256,6 +267,8 @@
         if self._driver_control:
             self._driver_control("set_passthrough", False)
 
+        self._wire_vo_driver(self._vo)
+
 
     def configure_audio(self, driver):
         """
@@ -289,6 +302,8 @@
                 num = self.config.audio.channels
                 set('audio.output.speaker_arrangement', channels[num])
 
+        self._wire_ao_driver(self._ao)
+
 
     def configure_stream(self):
         """
@@ -296,7 +311,7 @@
         """
         self._stream = self._xine.new_stream(self._ao, self._vo)
         #self._stream.set_parameter(xine.PARAM_VO_CROP_BOTTOM, 10)
-        self._stream.signals["event"].connect_weak(self.handle_xine_event)
+        self._stream.signals["event"].connect_weak(self._handle_xine_event)
 
         # self._noise_post = self._xine.post_init("noise", video_targets = 
[self._vo])
         # self._noise_post.set_parameters(luma_strength = 3, quality = 
"temporal")

Modified: trunk/popcorn/src/backends/xine/player.py
==============================================================================
--- trunk/popcorn/src/backends/xine/player.py   (original)
+++ trunk/popcorn/src/backends/xine/player.py   Thu Nov 30 04:57:56 2006
@@ -211,12 +211,34 @@
             
window.signals["map_event"].connect_weak(self._window_visibility_event)
             
window.signals["unmap_event"].connect_weak(self._window_visibility_event)
             
window.signals["expose_event"].connect_weak(self._window_expose_event)
+            if self._xine:
+                if old_window and window.get_display() == 
old_window.get_display():
+                    # New window on same display, no need to reconfigure the 
vo,
+                    # we can just point at the new window.
+                    self._xine.window_changed(window.get_id(), None, None, 
None)
+                elif self._xine_configured:
+                    # No previous window, must reconfigure vo.
+                    self._xine.configure_video(window.get_id(), 
self.get_aspect())
 
         # Sends a window_changed command to slave.
-        if window:
+        if window and self._xine:
             self._window_visibility_event()
 
 
+    def configure(self):
+        if self._xine_configured:
+            return
+
+        self._xine_configured = True
+        self._xine.set_config(self._config)
+        if self._window:
+            self._xine.configure_video(self._window.get_id(), 
self.get_aspect())
+        else:
+            self._xine.configure_video(None, None)
+        self._xine.configure_audio(self._config.audio.driver)
+        self._xine.configure_stream()
+
+
     #
     # Methods for MediaPlayer subclasses
     #
@@ -232,18 +254,10 @@
         if not self._xine:
             self._child_spawn()
 
-        if not self._xine_configured:
-            self._xine_configured = True
-            self._xine.set_config(self._config)
-            if self._window:
-                self._xine.configure_video(self._window.get_id(), 
self.get_aspect())
-            else:
-                self._xine.configure_video(None, None)
-            self._xine.configure_audio(self._config.audio.driver)
-            self._xine.configure_stream()
+        self.configure()
         self._position = 0.0
         self._audio_delay = 0.0
-        log.debug('xine open')
+        log.debug('xine open %s' % self._mrl)
         self._xine.open(self._mrl)
         self._state = STATE_OPENING
 
@@ -406,6 +420,7 @@
         else:
             self._check_new_frame_timer.stop()
 
+        log.debug('Setting frame output: vo=%s notify=%s size=%s' % (vo, 
notify, size))
         self._xine.set_frame_output_mode(vo, notify, size)
 
 

Modified: trunk/popcorn/src/generic.py
==============================================================================
--- trunk/popcorn/src/generic.py        (original)
+++ trunk/popcorn/src/generic.py        Thu Nov 30 04:57:56 2006
@@ -80,10 +80,8 @@
         self._player = None
         self._size = (0,0)
         self._aspect = None
-        
-        if window:
-            self._size = window.get_size()
-        self._window = window
+        self.set_window(window)
+
         self._config = config
         
         self.signals = {
@@ -116,7 +114,16 @@
         self._pending = []
         self._blocked = False
         self._failed_player = []
-        
+ 
+
+    def set_window(self, window):
+        if window:
+            self._size = window.get_size()
+        self._window = window
+        if self._player:
+            self._player.set_window(self._window)
+            self._player.set_size(self._size, self._aspect)
+
 
     def _get_player_class(self, player=None):
         """
@@ -149,6 +156,13 @@
             # TODO: What happens if the user tries to open a new file
             # while we are trying to find a good player for the old
             # mrl?
+            # FIXME: if user calls open() and stop(), we ends up here but
+            # this isn't a failed player or broken state.
+            # FIXME: if user calls stop() on a playing video, then open(),
+            # then play(), we could end up here, because stop() does not affect
+            # state in xine backend until child acknowledges, but open()
+            # sets state to STATE_OPENING immediately.  So we go from 
+            # STATE_OPENING to STATE_IDLE.
             self._failed_player.append(self.get_player_id())
             # FIXME: why is this here? If we delete our pending functions
             # a 'play' after open may get missed. So let's see what happens
@@ -215,7 +229,7 @@
         self._blocked = False
 
 
-    @required_states(STATE_NOT_RUNNING)
+    @required_states(STATE_NOT_RUNNING, STATE_SHUTDOWN)
     def _create_player(self, cls):
         """
         Create a player based on cls.
@@ -261,8 +275,7 @@
         if not self._player:
             self._create_player(cls)
         else:
-            if not self.get_state() in \
-                   (STATE_IDLE, STATE_NOT_RUNNING, STATE_SHUTDOWN):
+            if self.get_state() not in (STATE_IDLE, STATE_NOT_RUNNING, 
STATE_SHUTDOWN):
                 self._player.stop()
             if not isinstance(self._player, cls):
                 self._player.release()
@@ -593,7 +606,7 @@
         """
         # TODO: ability to specify colorspace of frame.
         if self._player:
-            return self._player.set_frame_output_mode()
+            return self._player.set_frame_output_mode(vo, notify, size)
 
 
     def unlock_frame_buffer(self):

Modified: trunk/popcorn/src/utils/ipc.py
==============================================================================
--- trunk/popcorn/src/utils/ipc.py      (original)
+++ trunk/popcorn/src/utils/ipc.py      Thu Nov 30 04:57:56 2006
@@ -57,6 +57,7 @@
         """
         Send command to child.
         """
+        log.debug('Send IPC to child: %s %s %s' % (self._cmd, args, kwargs))
         self._fd(repr((self._cmd, args, kwargs)) + "\n")
 
 
@@ -88,6 +89,7 @@
             # ipc command from child
             command, args, kwargs = eval(line[5:])
             cmd = getattr(self._parent, "_child_" + command, None)
+            log.debug('Receive IPC from child: %s %s %s' % (command, args, 
kwargs))
             if cmd:
                 cmd(*args, **kwargs)
                 return True
@@ -181,6 +183,7 @@
             line = self._stdin_data[:self._stdin_data.find('\n')]
             self._stdin_data = self._stdin_data[self._stdin_data.find('\n')+1:]
             command, args, kwargs = eval(line)
+            log.debug('Receive IPC from parent: %s %s %s' % (command, args, 
kwargs))
             reply = getattr(self, command)(*args, **kwargs)
 
 

-------------------------------------------------------------------------
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

Reply via email to