コード例 #1
0
 def __init__(self, app, remote):
     self.tuner_chidx = 0  # Current channel, index into config.TV_CHANNELS
     self.app_mode = 'tv'
     self.fc = FreevoChannels()
     self.current_vg = None
     self.xawtv_prog = app
     self.remote_prog = remote
コード例 #2
0
ファイル: upsoon.py プロジェクト: spartrekus/freevo1
    def __init__(self, standalone=False):
        """
        init the upsoon plugin
        """
        logger.log( 9, 'upsoon.PluginInterface.__init__()')
        plugin.DaemonPlugin.__init__(self)
        plugin.register(self, 'upsoon')
        self.standalone = standalone
        self.lock = thread.allocate_lock()
        self.running = True
        self.timer = Timer(self.timer_handler).start(15)
        self.event = EventHandler(self.event_handler)
        #self.event.register(('VIDEO_START', 'VIDEO_END'))
        self.event.register()

        self.recordclient = RecordClient()

        self.fc = FreevoChannels()
        self.rdev = config.RADIO_DEVICE

        self.next_program = None
        self.announced = False
        self.seconds_before_announce = config.TV_UPSOON_ANNOUNCE
        self.seconds_before_start = config.TV_UPSOON_BEFORE_START
        self.pending_lockfile = config.FREEVO_CACHEDIR + '/record.soon'
        self.tv_lockfile = None # lockfile of recordserver
        self.stopped = None     # flag that tells upsoon what stopped
        if os.path.exists(self.pending_lockfile):
            os.remove(self.pending_lockfile)
            logger.debug('%r lockfile removed', self.pending_lockfile)
コード例 #3
0
    def __init__(self):
        """
        init the upsoon plugin
        """
        _debug_('__init__(self)', 2)
        plugin.DaemonPlugin.__init__(self)
        self.lock = thread.allocate_lock()
        self.poll_interval = 1500  #15 secs
        self.poll_menu_only = 0
        self.event_listener = 1
        plugin.register(self, 'upsoon')

        server_string = 'http://%s:%s/' % (config.RECORDSERVER_IP,
                                           config.RECORDSERVER_PORT)
        _debug_('%s' % server_string)
        self.server = xmlrpclib.Server(server_string, allow_none=1)
        _debug_('%s' % self.server)

        self.serverup = None
        self.next_program = self.findNextProgram()
        _debug_('%s' % (self.next_program))

        self.fc = FreevoChannels()

        self.seconds_before_announce = 120
        self.seconds_before_start = 60
        self.pending_lockfile = config.FREEVO_CACHEDIR + '/record.soon'
        self.tv_lockfile = None  # lockfile of recordserver
        self.stopped = False  # flag that tells upsoon stopped the tv, not the user
コード例 #4
0
    def __init__(self):

        self.ivtv_init = False
        self.fc = FreevoChannels()
        self.curr_channel = None
        self.embed = None
        self.stack = []
コード例 #5
0
ファイル: upsoon.py プロジェクト: 1147279/SoftwareProject
    def __init__(self, standalone=False):
        """
        init the upsoon plugin
        """
        _debug_('upsoon.PluginInterface.__init__()', 2)
        plugin.DaemonPlugin.__init__(self)
        plugin.register(self, 'upsoon')
        self.standalone = standalone
        self.lock = thread.allocate_lock()
        self.running = True
        self.timer = Timer(self.timer_handler).start(15)
        self.event = EventHandler(self.event_handler)
        #self.event.register(('VIDEO_START', 'VIDEO_END'))
        self.event.register()

        self.recordclient = RecordClient()

        self.fc = FreevoChannels()
        self.rdev = config.RADIO_DEVICE

        self.next_program = None
        self.seconds_before_announce = 120
        self.seconds_before_start = 60
        self.pending_lockfile = config.FREEVO_CACHEDIR + '/record.soon'
        self.tv_lockfile = None  # lockfile of recordserver
        self.stopped = None  # flag that tells upsoon what stopped
コード例 #6
0
 def __init__(self, xine):
     """ TunerControl constructor """
     self.xine = xine
     self.ivtv_init = False
     self.fc = FreevoChannels()
     self.curr_channel = None
     self.embed = None
     self.stack = []
コード例 #7
0
    def run(self):
        while 1:
            if DEBUG: print('Record_Thread::run: mode=%s' % self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                rc.post_event(Event('RECORD_START', arg=self.prog))
                if DEBUG: print 'Record_Thread::run: started recording'

                fc = FreevoChannels()
                if DEBUG: print 'CHAN: %s' % fc.getChannel()

                (v_norm, v_input, v_clist, v_dev) = config.TV_SETTINGS.split()

                v = tv.ivtv.IVTV(v_dev)

                v.init_settings()
                vg = fc.getVideoGroup(self.prog.tunerid, False)

                if DEBUG: print 'Setting Input to %s' % vg.input_num
                v.setinput(vg.input_num)

                if DEBUG: print 'Setting Channel to %s' % self.prog.tunerid
                fc.chanSet(str(self.prog.tunerid), False)

                if DEBUG: v.print_settings()

                now = time.time()
                stop = now + self.prog.rec_duration

                time.sleep(2)

                v_in = open(v_dev, 'r')
                v_out = open(self.prog.filename, 'w')

                while time.time() < stop:
                    buf = v_in.read(CHUNKSIZE)
                    v_out.write(buf)
                    if self.mode == 'stop':
                        break

                v_in.close()
                v_out.close()
                v.close()
                v = None

                self.mode = 'idle'

                rc.post_event(Event('RECORD_STOP', arg=self.prog))
                if DEBUG: print('Record_Thread::run: finished recording')

            else:
                self.mode = 'idle'

            time.sleep(0.5)
コード例 #8
0
    def run(self):
        while 1:
            if DEBUG: print('Record_Thread::run: mode=%s' % self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                rc.post_event(Event('RECORD_START', arg=self.prog))
                if DEBUG: print('Record_Thread::run: cmd=%s' % self.command)

                fc = FreevoChannels()
                if DEBUG: print 'CHAN: %s' % fc.getChannel()

                (v_norm, v_input, v_clist, v_dev) = config.TV_SETTINGS.split()

                v = tv.ivtv.IVTV(v_dev)

                v.init_settings()
                self.vg = fc.getVideoGroup(self.prog.tunerid, False)

                if DEBUG: print 'Using video device %s' % self.vg.vdev
                if DEBUG: print 'Setting Input to %s' % self.vg.input_num
                v.setinput(self.vg.input_num)

                if DEBUG: print 'Setting Channel to %s' % self.prog.tunerid
                fc.chanSet(str(self.prog.tunerid), False)

                if DEBUG: v.print_settings()

                self.app = RecordApp(self.command)

                while self.mode == 'record' and self.app.isAlive():
                    self.autokill -= 0.5
                    time.sleep(0.5)
                    if self.autokill <= 0:
                        if DEBUG:
                            print 'autokill timeout, stopping recording'
                        self.mode = 'stop'

                if self.app.isAlive():
                    # might not want to do this is PDC is valid, programme may be delayed
                    if DEBUG: print('Record_Thread::run: past wait!!')
                    rc.post_event(
                        Event(OS_EVENT_KILL, (self.app.child.pid, 15)))
                    self.app.kill()

                rc.post_event(Event('RECORD_STOP', arg=self.prog))
                if DEBUG: print('Record_Thread::run: finished recording')

                self.mode = 'idle'
            else:
                self.mode = 'idle'
            time.sleep(0.5)
コード例 #9
0
ファイル: record.py プロジェクト: 1147279/SoftwareProject
 def __init__(self, manager):
     """
     Initialise the recording thread passing in the DVBStreamerControl object to use to
     control instances of dvbstreamer.
     """
     threading.Thread.__init__(self)
     self.fc = FreevoChannels()
     self.manager = manager
     self.mode = 'idle'
     self.mode_flag = threading.Event()
     self.prog = None
     self.app = None
コード例 #10
0
    def __init__(self):
        # Disable this plugin if not loaded by record_server.
        if string.find(sys.argv[0], 'recordserver') == -1:
            return

        if DEBUG: print 'ACTIVATING GENERIC RECORD PLUGIN'

        self.fc = FreevoChannels()
        self.thread = Record_Thread()
        self.thread.setDaemon(1)
        self.thread.mode = 'idle'
        self.thread.start()
コード例 #11
0
    def __init__(self, manager, path, size):
        self.name      = 'vlc'
        self.app_mode  = 'tv'
        self.app       = None
        self.adapter_in_use = -1
        self.fc = FreevoChannels()
        self.path = path
        self.size = size
        self.buffer = ring_buffer.RingBuffer(size, path)
        self.last_channel = None
        self.subtitles = False
        self.paused = False
        self.stop_time = 0
        self.state = STATE_IDLE
        self.manager = manager
        self.udp_receiver = UDPReceiver(self.buffer, WAIT_FOR_DATA_TIMEOUT)
        self.slave_server = SlaveServer(self.buffer, self)
        self.fill = 0
        self.cur_audio      = None
        self.cur_sub        = None
        self.cur_audiodev   = None
        self.lastchan       = None

        self.timer = kaa.Timer(self.__update_data_from_vlc)
        self.timer_start = kaa.OneShotTimer( self.__update_data_from_vlc)
        self.timer_disablebuffering = kaa.OneShotTimer( self.disable_buffering)

        if hasattr(config, 'LIVE_PAUSE_BUFFER_TIMEOUT'):
            self. buffering_timeout=config.LIVE_PAUSE_BUFFER_TIMEOUT
        else: # Disable after 5min if not LIVE_PAUSE_BUFFERING_TIMEOUT
            self.buffering_timeout= 5 * 60

        # Create the command used to start vlc.
        # NOTE: We add the slave server MRL twice so that we can toggle between
        # them, this allows use to effectively reset vlc rendering pipeline and
        # make it possible to seek quickly.
        self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
                       config.VLC_COMMAND.split(' ')  + \
                       [ '--intf', 'rc' ] + \
                       ['--no-interact','--rc-fake-tty'] + \
                       [ '--sub-filter' ,'marq' ] + \
                       [ '--marq-marquee' ,'Playing' ] + \
                       [ '--marq-position','4'] + \
                       [ '--fullscreen', self.slave_server.get_vlc_mrl(),
                                         self.slave_server.get_vlc_mrl()]

        if not rc.PYLIRC and '--no-lirc' in self.command:
            self.command.remove('--no-lirc')

        self.udp_receiver.start()
        self.slave_server.start()
コード例 #12
0
    def __init__(self):
        # Disable this plugin if not loaded by record_server.
        if string.find(sys.argv[0], 'recordserver') == -1:
            return

        if DEBUG: print 'ACTIVATING VBI2SRT RECORD PLUGIN'

        self.vg = None
        self.fc = FreevoChannels()
        self.tuner_chidx = 0  # Current channel, index into config.TV_CHANNELS
        self.thread = Record_Thread()
        self.thread.setDaemon(1)
        self.thread.mode = 'idle'
        self.thread.start()
コード例 #13
0
    def run(self):
        _debug_('Record_Thread.run()', 2)
        while 1:
            _debug_('mode=%s' % self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                rc.post_event(Event('RECORD_START', arg=self.prog))

                fc = FreevoChannels()
                _debug_('channel %s' % fc.getChannel())

                self.vg = fc.getVideoGroup(self.prog.tunerid, False)

                v = tv.ivtv.IVTV(self.vg.vdev)

                v.init_settings()

                _debug_('Using video device=%r' % self.vg.vdev)

                _debug_('Setting Channel to %r' % self.prog.tunerid)
                fc.chanSet(str(self.prog.tunerid), False)

                _debug_('command %r' % self.command)
                self.app = RecordApp(self.command)
                _debug_('app child pid: %s' % self.app.child.pid)

                while self.mode == 'record' and self.app.isAlive():
                    self.autokill -= 0.5
                    time.sleep(0.5)
                    if self.autokill <= 0:
                        _debug_('autokill timeout, stopping recording')
                        self.mode = 'stop'

                if self.app.isAlive():
                    # might not want to do this is PDC is valid, programme may be delayed
                    _debug_('past wait!!')
                    rc.post_event(
                        Event(OS_EVENT_KILL, (self.app.child.pid, 15)))
                    self.app.kill()

                rc.post_event(Event('RECORD_STOP', arg=self.prog))
                _debug_('finished recording')

                self.mode = 'idle'
            else:
                self.mode = 'idle'
            time.sleep(0.5)
コード例 #14
0
ファイル: xine.py プロジェクト: 1147279/SoftwareProject
    def __init__(self, type):
        self.name      = 'xine'

        self.app_mode  = 'tv'
        self.xine_type = type
        self.app       = None

        self.fc = FreevoChannels()

        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(' ')
コード例 #15
0
ファイル: record.py プロジェクト: 1147279/SoftwareProject
    def __init__(self, manager):
        """
        Initialise the recorder passing in the DVBStreamerControl object to use to
        control instances of dvbstreamer.
        """
        # Disable this plugin if not loaded by record_server.
        if sys.argv[0].find('recordserver') == -1:
            return

        self.fc = FreevoChannels()
        self.thread = Record_Thread(manager)
        self.thread.setDaemon(1)
        self.thread.mode = 'idle'
        self.thread.start()
コード例 #16
0
 def play(self, arg=None, menuw=None):
     """ Start watching TV """
     logger.log(9, 'play(arg=%r, menuw=%r)', arg, menuw)
     # watching TV should only be possible from the guide
     if not self.context == 'guide':
         rc.post_event(MENU_SELECT)
         return
     now = time.time()
     if menuw: menuw.delete_submenu()
     # Check if the selected program is >7 min in the future
     if self.prog.start > now + (7 * 60):
         if menuw: menuw.show()
         # this program is in the future
         if self.scheduled:
             msgtext = _(
                 'Do you want to remove the Program from the record schedule?'
             )
             confirmbtn = _('Remove')
         else:
             msgtext = _(
                 'This Program is in the future. Do you want to record it?')
             confirmbtn = _('Record')
         dialog.show_confirmation(msgtext,
                                  lambda: self.toggle_rec(menuw=menuw),
                                  proceed_text=confirmbtn)
         return
     else:
         # check if the device is free
         fc = FreevoChannels()
         # for that we need the name of the lock file
         suffix = fc.getVideoGroup(self.prog.channel_id, True,
                                   CHANNEL_ID).vdev
         suffix = suffix.split('/')[-1]
         tvlockfile = config.FREEVO_CACHEDIR + '/record.' + suffix
         if os.path.exists(tvlockfile):
             if menuw: menuw.show()
             # XXX: In the future add the options to watch what we are
             #      recording or cancel it and watch TV.
             msgtext = _('Sorry, you cannot watch TV while recording. ')
             msgtext += _('If this is not true then remove ')
             msgtext += tvlockfile + '.'
             dialog.show_alert(msgtext)
         else:
             # everything is ok, we can start watching!
             self.parent.hide()
             self.parent.player('tv', self.prog.channel_id)
コード例 #17
0
 def writeTvtimeXML(self):
     tvtimexml = os.path.join(os.environ['HOME'], '.tvtime', 'tvtime.xml')
     configcmd = os.path.join(os.path.dirname(config.TVTIME_CMD), "tvtime-configure")
     #cf_norm, cf_input, cf_clist, cf_device = config.TV_SETTINGS.split()
     fc = FreevoChannels()
     vg = fc.getVideoGroup(config.TV_CHANNELS[0][2], True)
     cf_norm = vg.tuner_norm
     cf_input = vg.input_num
     cf_device = vg.vdev
     s_norm = cf_norm.upper()
     daoptions = ''
     if os.path.isfile(tvtimexml):
         daoptions = ' -F ' + tvtimexml
     if self.xmltv_supported:
         daoptions += ' -d %s -n %s -t %s' % (cf_device, s_norm, config.XMLTV_FILE)
     else:
         daoptions += ' -d %s -n %s' % (cf_device, s_norm)
     if hasattr(config, "TV_TVTIME_SETUP_OPTS") and config.TV_TVTIME_SETUP_OPTS:
         daoptions += ' %s' % config.TV_TVTIME_SETUP_OPTS
     os.system(configcmd+daoptions)
コード例 #18
0
ファイル: tvguide.py プロジェクト: 1147279/SoftwareProject
    def __init__(self, start_time, player, menuw):
        Item.__init__(self)

        self.n_items, hours_per_page = skin.items_per_page(('tv', self))
        stop_time = start_time + hours_per_page * 60 * 60

        msgtext = _('Preparing the program guide')
        guide = epg_xmltv.get_guide(PopupBox(text=msgtext))
        channels = guide.GetPrograms(start=start_time + 1, stop=stop_time - 1)
        if not channels:
            AlertBox(text=_('TV Guide is corrupt!')).show()
            return

        selected = None
        for chan in channels:
            if chan.programs:
                selected = chan.programs[0]
                break

        self.col_time = 30  # each col represents 30 minutes
        self.n_cols = (stop_time - start_time) / 60 / self.col_time
        self.player = player

        self.type = 'tv'
        self.menuw = menuw
        self.visible = True
        self.select_time = start_time
        self.last_update = 0

        self.lastinput_value = None
        self.lastinput_time = None

        self.update_schedules(force=True)
        self.fc = FreevoChannels()

        self.rebuild(start_time, stop_time, guide.chan_list[0].id, selected)
        self.event_context = 'tvmenu'
        menuw.pushmenu(self)
コード例 #19
0
    def __init__(self, type, version, manager, path, size):
        self.name = 'xine'
        self.app_mode = 'tv'
        self.xine_type = type
        self.version = version
        self.app = None
        self.adapter_in_use = -1
        self.fc = FreevoChannels()
        self.path = path
        self.size = size
        self.buffer = ring_buffer.RingBuffer(size, path)
        self.last_channel = None
        self.subtitles = False
        self.paused = False
        self.stop_time = 0
        self.state = STATE_IDLE
        self.manager = manager
        self.udp_receiver = UDPReceiver(self.buffer, WAIT_FOR_DATA_TIMEOUT)
        self.slave_server = SlaveServer(self.buffer, self)

        # Create the command used to start xine.
        # NOTE: We add the slave server MRL twice so that we can toggle between
        # them, this allows use to effectively reset Xine rendering pipeline and
        # make it possible to seek quickly.
        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(' ') + \
                       [self.slave_server.get_xine_mrl(),
                        self.slave_server.get_xine_mrl()]

        if not rc.PYLIRC and '--no-lirc' in self.command:
            self.command.remove('--no-lirc')

        self.udp_receiver.start()
        self.slave_server.start()
コード例 #20
0
ファイル: ivtv_record.py プロジェクト: spartrekus/freevo1
    def run(self):
        logger.log(9, 'Record_Thread.run()')
        while 1:
            logger.debug('Record_Thread::run: mode=%s', self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                try:
                    logger.info('Record_Thread::run: started recording')

                    fc = FreevoChannels()
                    logger.debug('Channel: %s', fc.getChannel())

                    vg = fc.getVideoGroup(self.prog.tunerid, False)

                    logger.debug('Opening device %r', vg.vdev)
                    v = tv.ivtv.IVTV(vg.vdev)

                    v.init_settings()

                    logger.debug('Setting input to %r', vg.input_type)
                    v.setinputbyname(vg.input_type)

                    cur_std = v.getstd()
                    try:
                        new_std = V4L2.NORMS.get(vg.tuner_norm)
                        if cur_std != new_std:
                            logger.debug('Setting standard to %s', new_std)
                            v.setstd(new_std)
                    except:
                        logger.error(
                            "Videogroup norm value '%s' not from NORMS: %s",
                            vg.tuner_norm, V4L2.NORMS.keys())

                    logger.debug('Setting channel to %r', self.prog.tunerid)
                    fc.chanSet(str(self.prog.tunerid), False)

                    # Setting the input sound level on the PVR card
                    channel = self.prog.tunerid
                    try:
                        # lookup the channel name in TV_CHANNELS
                        for pos in range(len(config.TV_CHANNELS)):
                            entry = config.TV_CHANNELS[pos]
                            if str(channel) == str(entry[2]):
                                channel_index = pos
                                break
                    except ValueError:
                        pass

                    logger.debug(
                        'SetAudioByChannel: Channel: %r TV_CHANNEL pos(%d)',
                        channel, channel_index)
                    try:
                        ivtv_avol = vg.avol
                    except AttributeError:
                        ivtv_avol = 0
                    if ivtv_avol <= 0:
                        logger.debug(
                            'SetAudioByChannel: The tv_video group for %r doesn\'t set the volume',
                            channel)
                    else:
                        # Is there a specific volume level in TV_CHANNELS_VOLUME
                        avol_percent = 100
                        try:
                            # lookup the channel name in TV_CHANNELS
                            for pos in range(len(config.TV_CHANNELS_VOLUME)):
                                if config.TV_CHANNELS_VOLUME[pos][
                                        0] == config.TV_CHANNELS[
                                            channel_index][0]:
                                    avol_percent = config.TV_CHANNELS_VOLUME[
                                        pos][1]
                                    break
                        except:
                            pass

                        try:
                            avol_percent = int(avol_percent)
                        except ValueError:
                            avol_percent = 100

                        avol = int(ivtv_avol * avol_percent / 100)
                        if avol > 65535:
                            avol = 65535
                        if avol < 0:
                            avol = 0
                        logger.debug(
                            'SetAudioByChannel: Current PVR Sound level is : %s',
                            v.getctrl(0x00980905))
                        logger.debug(
                            'SetAudioByChannel: Set the PVR Sound Level to : %s (%s * %s)',
                            avol, ivtv_avol, avol_percent)
                        v.setctrl(0x00980905, avol)
                        logger.debug(
                            'SetAudioByChannel: New PVR Sound level is : %s',
                            v.getctrl(0x00980905))

                    if vg.cmd != None:
                        logger.debug("Running command %r", vg.cmd)
                        retcode = os.system(vg.cmd)
                        logger.debug("exit code: %g", retcode)

                    now = time.time()
                    stop = now + self.prog.rec_duration

                    rc.post_event(Event('RECORD_START', arg=self.prog))
                    time.sleep(2)

                    v_in = open(vg.vdev, 'r')
                    v_out = open(self.prog.filename, 'w')

                    logger.debug('Recording from %r to %r in %s byte chunks',
                                 vg.vdev, self.prog.filename, CHUNKSIZE)
                    while time.time() < stop:
                        buf = v_in.read(CHUNKSIZE)
                        v_out.write(buf)
                        if self.mode == 'stop':
                            logger.info('Recording stopped')
                            break

                    v_in.close()
                    v_out.close()
                    v.close()
                    v = None

                    self.mode = 'idle'

                    rc.post_event(Event('RECORD_STOP', arg=self.prog))
                    logger.info('Record_Thread::run: finished recording')
                except Exception, why:
                    logger.critical('%s', why)
                    return

            else:
                self.mode = 'idle'

            time.sleep(0.5)
コード例 #21
0
ファイル: tvtime.py プロジェクト: spartrekus/freevo1
 def __init__(self):
     self.event_context = 'tv'
     self.fc = FreevoChannels()
     self.current_vg = None
     self.optionD_supported = False
     self.xmltv_supported = False
コード例 #22
0
 def __init__(self):
     self.tuner_chidx = 0  # Current channel, index into config.TV_CHANNELS
     self.app_mode = 'tv'
     self.fc = FreevoChannels()
     self.current_vg = None
コード例 #23
0
ファイル: __init__.py プロジェクト: spartrekus/freevo1
    def __init__(self, player):
        self.name = 'livepause'
        self.event_context  = 'tv'

        self.fc = FreevoChannels()

        self.backend = backend.get_backend()
        self.backend.set_mode(player.mode)

        self.last_channel = None
        self.stop_time = 0
        self.data_started_timer = kaa.OneShotTimer(self.__buffering_data_timedout)
        self.disable_buffering_timer = kaa.OneShotTimer(self.__disable_buffering_timeout)

        self.state = State.IDLE
        self.player = player

        self.changing_channel = False

        self.subtitles = None
        self.subtitle_index = -1

        self.audio_langs = None
        self.audio_lang_index = -1

        self.recording = False

        self.state_dialog = None

        # Setup Event Maps
        self.event_maps = {}
        self.event_maps[State.IDLE] = {
            'READER_OVERTAKEN'    : self.__idle_reader_overtaken,
            }

        self.event_maps[State.TUNING] = {
            'DATA_STARTED' : self.__tuning_data_started,
            'DATA_TIMEDOUT': self.__tuning_data_timedout,
            'PLAY_END'     : self.__handle_stop,
            'USER_END'     : self.__handle_stop,
            'STOP'         : self.__handle_stop
            }

        self.event_maps[State.BUFFERING] = {
            'DATA_ACQUIRED': self.__buffering_data_acquired,
            'DATA_TIMEDOUT': self.__buffering_data_timedout,
            'PLAY_END'     : self.__handle_stop,
            'USER_END'     : self.__handle_stop,
            'STOP'         : self.__handle_stop
            }

        self.event_maps[State.PLAYING] = {
            'PLAY'                : self.__playing_play_pause,
            'PAUSE'               : self.__playing_play_pause,
            'PLAY_END'            : self.__handle_stop,
            'USER_END'            : self.__handle_stop,
            'STOP'                : self.__handle_stop,
            'TV_CHANNEL_UP'       : self.__playing_tv_channel_up,
            'TV_CHANNEL_DOWN'     : self.__playing_tv_channel_down,
            'TV_CHANNEL_NUMBER'   : self.__playing_tv_channel_number,
            'TV_START_RECORDING'  : self.__playing_tv_record,
            'SAVE_STARTED'        : self.__playing_tv_record_start,
            'SAVE_FINISHED'       : self.__playing_tv_record_stop,
            'BUTTON'              : self.__playing_button_pressed,
            'TOGGLE_OSD'          : self.__playing_display_info,
            'SEEK'                : self.__playing_seek,
            'SECONDS_LEFT'        : self.__playing_seconds_left,
            'READER_OVERTAKEN'    : self.__playing_reader_overtaken,
            'DATA_ACQUIRED'       : None,
            'DATA_TIMEDOUT'       : None,
            'VIDEO_NEXT_FILLMODE' : None,
            'VIDEO_NEXT_AUDIOMODE': None,
            'VIDEO_NEXT_AUDIOLANG': None, #self.__playing_toggle_audo_lang,
            'VIDEO_NEXT_SUBTITLE' : self.__playing_toggle_subtitles,
            }

        self.current_event_map = self.event_maps[self.state]
コード例 #24
0
    def run(self):
        _debug_('Record_Thread.run()', 2)
        while 1:
            _debug_('Record_Thread::run: mode=%s' % self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                try:
                    _debug_('Record_Thread::run: started recording', DINFO)

                    fc = FreevoChannels()
                    _debug_('Channel: %s' % (fc.getChannel()))

                    vg = fc.getVideoGroup(self.prog.tunerid, False)

                    _debug_('Opening device %r' % (vg.vdev))
                    v = tv.ivtv.IVTV(vg.vdev)

                    v.init_settings()

                    _debug_('Setting input to %r' % (vg.input_type))
                    v.setinputbyname(vg.input_type)

                    cur_std = v.getstd()
                    try:
                        new_std = V4L2.NORMS.get(vg.tuner_norm)
                        if cur_std != new_std:
                            _debug_('Setting standard to %s' % (new_std))
                            v.setstd(new_std)
                    except:
                        _debug_("Videogroup norm value '%s' not from NORMS: %s" % \
                            (vg.tuner_norm, V4L2.NORMS.keys()), DERROR)

                    _debug_('Setting channel to %r' % self.prog.tunerid)
                    fc.chanSet(str(self.prog.tunerid), False)

                    if vg.cmd != None:
                        _debug_("Running command %r" % vg.cmd)
                        retcode = os.system(vg.cmd)
                        _debug_("exit code: %g" % retcode)

                    now = time.time()
                    stop = now + self.prog.rec_duration

                    rc.post_event(Event('RECORD_START', arg=self.prog))
                    time.sleep(2)

                    v_in = open(vg.vdev, 'r')
                    v_out = open(self.prog.filename, 'w')

                    _debug_('Recording from %r to %r in %s byte chunks' %
                            (vg.vdev, self.prog.filename, CHUNKSIZE))
                    while time.time() < stop:
                        buf = v_in.read(CHUNKSIZE)
                        v_out.write(buf)
                        if self.mode == 'stop':
                            _debug_('Recording stopped', DINFO)
                            break

                    v_in.close()
                    v_out.close()
                    v.close()
                    v = None

                    self.mode = 'idle'

                    rc.post_event(Event('RECORD_STOP', arg=self.prog))
                    _debug_('Record_Thread::run: finished recording', DINFO)
                except Exception, why:
                    _debug_('%s' % (why), DCRITICAL)
                    return

            else:
                self.mode = 'idle'

            time.sleep(0.5)
コード例 #25
0
ファイル: upsoon.py プロジェクト: 1147279/SoftwareProject
        kaa.main.run()

    elif function == 'findnextprogram':

        def handler(result):
            print 'findnextprogram=%r' % (result, )
            print result.__dict__
            raise SystemExit

        server.findNextProgram(handler)
        kaa.main.run()

    elif function == 'isplayerrunning':

        def handler(result):
            print 'isplayerrunning=%r' % (result, )
            raise SystemExit

        server.isPlayerRunning(handler)
        kaa.main.run()

    else:
        fc = FreevoChannels()
        vg = fc.getVideoGroup('K10', False)
        print 'vg=%s' % vg
        print 'dir(%s)' % dir(vg)
        for it in dir(vg):
            print '   %s:%s' % (it, eval('vg.' + it))
        vdev = vg.vdev
        print 'vdev=%s' % vdev