Exemplo n.º 1
0
    def __init__(self, command, mplayer):
        self.RE_TIME = re.compile("^[AV]: *([0-9]+)").match
        self.RE_VO = re.compile("^VO: \[.+\] \d+x\d+ => (\d+)x(\d+)").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
        self.stdout_plugins = []
        self.elapsed_plugins = []
        for p in plugin.get('mplayer_video'):
            if hasattr(p, 'stdout'):
                self.stdout_plugins.append(p)
            if hasattr(p, 'elapsed'):
                self.elapsed_plugins.append(p)

        self.output_event = threading.Event()
        self.get_property_ans = None

        if config.MPLAYER_RATE_SET_FROM_VIDEO:
            # we set a monitor's refresh rate that matches the FPS of the movie
            screen = xrandr.get_current_screen()

            # first we save the current rate
            self.rate = screen.get_current_rate()
            logger.info('Current refresh rate: %s', self.rate)

            fps = self.item.getattr('fps')

            if fps:
                # get the rate mapping
                rate = config.MPLAYER_RATE_MAP[fps]

                if rate:
                    screen.set_refresh_rate(rate[1])
                    screen.apply_config()
                else:
                    logger.warning('Unable to set refresh rate to %s', fps)
            else:
                logger.warning('Unknown refresh rate: %s', fps)

        # init the child (== start the threads)
        childapp.ChildApp2.__init__(self, command, callback_use_rc=False)
Exemplo n.º 2
0
    def __init__(self, command, mplayer):
        self.RE_TIME   = re.compile("^[AV]: *([0-9]+)").match
        self.RE_VO     = re.compile("^VO: \[.+\] \d+x\d+ => (\d+)x(\d+)").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
        self.stdout_plugins  = []
        self.elapsed_plugins = []
        for p in plugin.get('mplayer_video'):
            if hasattr(p, 'stdout'):
                self.stdout_plugins.append(p)
            if hasattr(p, 'elapsed'):
                self.elapsed_plugins.append(p)

        self.output_event = threading.Event()
        self.get_property_ans = None

        if config.MPLAYER_RATE_SET_FROM_VIDEO:
            # we set a monitor's refresh rate that matches the FPS of the movie
            screen = xrandr.get_current_screen()

            # first we save the current rate
            self.rate = screen.get_current_rate()
            logger.info('Current refresh rate: %s', self.rate)

            fps = self.item.getattr('fps')
            
            if fps:
                # get the rate mapping
                rate = config.MPLAYER_RATE_MAP[fps]

                if rate:
                    screen.set_refresh_rate(rate[1])
                    screen.apply_config()
                else:
                    logger.warning('Unable to set refresh rate to %s', fps)
            else:
                logger.warning('Unknown refresh rate: %s', fps)

        # init the child (== start the threads)
        childapp.ChildApp2.__init__(self, command, callback_use_rc=False)
Exemplo n.º 3
0
def get_screens():
    outputs = []
    screen = xrandr.get_current_screen()
    for output in screen.get_outputs():
        if output.is_active():
            outputs.append({'x':screen.get_crtc_by_xid(output.get_crtc())._info.contents.x,
                            'y':screen.get_crtc_by_xid(output.get_crtc())._info.contents.y,
                            'w':screen.get_crtc_by_xid(output.get_crtc())._info.contents.width,
                            'h':screen.get_crtc_by_xid(output.get_crtc())._info.contents.height})
    return outputs
Exemplo n.º 4
0
    def stop(self, cmd=''):
        """
        stop the child
        """
        # fist we call base class for cleanup
        childapp.ChildApp2.stop(self, cmd)
        
        if config.MPLAYER_RATE_SET_FROM_VIDEO:
            # now we reset the refresh rate to the default one
            screen = xrandr.get_current_screen()

            if config.MPLAYER_RATE_RESTORE:
                screen.set_refresh_rate(self.rate)
            else:
                screen.set_refresh_rate(config.MPLAYER_RATE_DEFAULT[1])

            screen.apply_config()
Exemplo n.º 5
0
    def stop(self, cmd=''):
        """
        stop the child
        """
        # fist we call base class for cleanup
        childapp.ChildApp2.stop(self, cmd)

        if config.MPLAYER_RATE_SET_FROM_VIDEO:
            # now we reset the refresh rate to the default one
            screen = xrandr.get_current_screen()

            if config.MPLAYER_RATE_RESTORE:
                screen.set_refresh_rate(self.rate)
            else:
                screen.set_refresh_rate(config.MPLAYER_RATE_DEFAULT[1])

            screen.apply_config()
Exemplo n.º 6
0
sys.path.insert(0,"../")
from xrandr import xrandr

def check_crtc_for_output(screen, crtc):
    # FIXME: port the rest of check_crtc_for_output from xrandr.c
    # check if this is in use by some other output and ignore it then
    for other in screen.outputs.values():
        if other.id == output.id:
            continue
        if other.get_crtc() == crtc.xid:
            return False
    return True

if __name__ == "__main__":

    screen = xrandr.get_current_screen()

    output = screen.outputs["VGA"]
    print "output: ", output.id
    print "active: ", output.is_active()
    print "ctrc: ", output.get_crtc()
    print "ctrcs: ", output.get_crtcs()

    # pick a random mode
    modes = screen._resources.contents.modes
    mode = modes[0]
    print "Setting: ", mode.width, mode.height

    # find output that is connected to crtc
    # 
    # (why can't I just get from xrandr what output is connected to