Beispiel #1
0
def start_recording(backend, channel_id):
    """
    Start recording the contents of the ring buffer to a file.
    @param reader: ChunkBufferReader instance used to read from the ring buffer.
    @param channel_id: The currently tuned channel.
    """
    buffer_info = backend.get_buffer_info()

    program = _get_program(buffer_info[3], channel_id)
    if program:
        filename_array = {
            'progname': String(program.title),
            'title': String(program.sub_title)
        }
        start_time = program.start
        end_time = program.stop
    else:
        filename_array = {
            'progname': String('Manual Recording'),
            'title': String('')
        }
        start_time = buffer_info[3]
        end_time = start_time + config.LIVE_PAUSE2_INSTANT_RECORD_LENGTH

    filemask = config.TV_RECORD_FILE_MASK % filename_array
    filemask = time.strftime(filemask, time.localtime(start_time))
    filename = os.path.join(config.TV_RECORD_DIR, progname2filename(filemask).rstrip(' -_:') + \
                            config.TV_RECORD_FILE_SUFFIX)

    _create_fxd(program, filename, start_time)
    backend.save(filename, start_time, end_time)
Beispiel #2
0
    def StartLiveRecording(self, event):
        """ start live recording """
        if event == INPUT_1:
            # record from this point on
            self.recordmode = 0
            name = self.tuner.GetChannelName()
            start = time.localtime()
            self.StopTimer()
            logger.debug('XineIvtv.StartLiveRecording: Record from now on')
        elif event == INPUT_2:
            # record from start of show
            self.recordmode = 1
            start_t, stop_t, name = self.tuner.GetInfo()
            start = time.localtime(start_t)
            self.StartTimer()
            logger.debug('XineIvtv.StartLiveRecording: Record from show start')
        elif event == INPUT_3:
            # record from start of stream
            self.recordmode = 2
            name = self.tuner.GetChannelName()
            start = time.localtime()
            self.StopTimer()
            logger.debug(
                'XineIvtv.StartLiveRecording: Record from stream start')

        if self.recordmode in [0, 1, 2]:
            # create fil ename and kick xine
            filename_array = {'progname': String(name), 'title': String('')}
            filemask = config.TV_RECORD_FILE_MASK % filename_array
            filemask = time.strftime(filemask, start)
            filename = tvutil.progname2filename(filemask).rstrip(' -_:')
            self.xine.Record(self.recordmode, filename)
            self.xine.ShowMessage(_('Recording: %s' % String(name)))
            logger.debug('XineIvtv.StartLiveRecording: filename=%s',
                         String(filename))
Beispiel #3
0
    def StartLiveRecording(self, event):
        """ start live recording """
        if event == INPUT_1:
            # record from this point on
            self.recordmode = 0
            name = self.tuner.GetChannelName()
            start = time.localtime()
            self.StopTimer()
            logger.debug('XineIvtv.StartLiveRecording: Record from now on')
        elif event == INPUT_2:
            # record from start of show
            self.recordmode = 1
            start_t, stop_t, name = self.tuner.GetInfo()
            start = time.localtime(start_t)
            self.StartTimer()
            logger.debug('XineIvtv.StartLiveRecording: Record from show start')
        elif event == INPUT_3:
            # record from start of stream
            self.recordmode = 2
            name = self.tuner.GetChannelName()
            start = time.localtime()
            self.StopTimer()
            logger.debug('XineIvtv.StartLiveRecording: Record from stream start')

        if self.recordmode in [ 0, 1, 2 ]:
            # create fil ename and kick xine
            filename_array = { 'progname': String(name), 'title': String('') }
            filemask = config.TV_RECORD_FILE_MASK % filename_array
            filemask = time.strftime(filemask, start)
            filename = tvutil.progname2filename(filemask).rstrip(' -_:')
            self.xine.Record(self.recordmode, filename)
            self.xine.ShowMessage(_('Recording: %s' % String(name)))
            logger.debug('XineIvtv.StartLiveRecording: filename=%s', String(filename))
Beispiel #4
0
def start_recording(backend, channel_id):
    """
    Start recording the contents of the ring buffer to a file.
    @param reader: ChunkBufferReader instance used to read from the ring buffer.
    @param channel_id: The currently tuned channel.
    """
    buffer_info = backend.get_buffer_info()

    program = _get_program(buffer_info[3], channel_id)
    if program:
        filename_array = { 'progname': String(program.title),
                           'title'   : String(program.sub_title) }
        start_time = program.start
        end_time = program.stop
    else:
        filename_array = { 'progname': String('Manual Recording'),
                           'title'   : String('') }
        start_time = buffer_info[3]
        end_time = start_time + config.LIVE_PAUSE2_INSTANT_RECORD_LENGTH

    filemask = config.TV_RECORD_FILE_MASK % filename_array
    filemask = time.strftime(filemask, time.localtime(start_time))
    filename = os.path.join(config.TV_RECORD_DIR, progname2filename(filemask).rstrip(' -_:') + \
                            config.TV_RECORD_FILE_SUFFIX)

    _create_fxd(program, filename, start_time)
    backend.save(filename, start_time, end_time)
Beispiel #5
0
    def eventhandler(self, event, menuw=None):
        """ Event handler """
        _debug_('%r app got %r event' % (self.mode, event.name))

        s_event = '%r' % event

        if event == STOP or event == PLAY_END:
            self.Stop()
            return True

        if event == PAUSE or event == PLAY:
            self.xine.Pause()
            return True

        if event == TV_START_RECORDING:
            start_t, stop_t, prog_s = self.tuner.GetInfo()
            filename_array = {'progname': String(prog_s), 'title': String('')}
            filemask = config.TV_RECORD_FILE_MASK % filename_array
            filemask = time.strftime(filemask, time.localtime(start_t))
            filename = tvutil.progname2filename(filemask).rstrip(' -_:')

            self.xine.Record(filename)
            self.xine.ShowMessage(_('Recording started\n'))
            return True

        if s_event == 'POPCHANNEL':
            self.tuner.PopChannel()
            return True

        if event == TV_CHANNEL_UP:
            # tune next channel
            self.tuner.NextChannel()
            return True

        if event == TV_CHANNEL_DOWN:
            # tune previous channel
            self.tuner.PrevChannel()
            return True

        if s_event.startswith('INPUT_'):
            eventInput = s_event[6]
            isNumeric = TRUE
            try:
                newinput_value = int(eventInput)
            except:
                #Protected against INPUT_UP, INPUT_DOWN, etc
                isNumeric = FALSE

            if isNumeric:
                # tune explicit channel
                newinput_time = int(time.time())

                if (self.lastinput_value != None):
                    # allow 2 seconds delay for multiple digit channels
                    if (newinput_time - self.lastinput_time < 2):
                        # this enables multiple (max 3) digit channel selection
                        if (self.lastinput_value >= 100):
                            self.lastinput_value = (self.lastinput_value % 100)
                        newinput_value = self.lastinput_value * 10 + newinput_value

                self.lastinput_value = newinput_value
                self.lastinput_time = newinput_time

                if config.XINE_TV_INPUT_REAL_CHANNELS:
                    self.tuner.SetChannelByNumber(newinput_value)
                else:
                    self.tuner.SetChannelByIndex(newinput_value)

                if newinput_value > 9:
                    # cancel intermediate channels
                    self.tuner.UnpushChannel()

            return True

        if event == SEEK:
            seeksteps = int(event.arg)
            direction = 0

            if seeksteps == 0:
                _debug_('Ignoring seek 0')
                return True

            if seeksteps < 0:
                direction = -1
                seeksteps = 0 - seeksteps
            else:
                direction = +1

            if config.XINE_TV_PROGRESSIVE_SEEK:
                seekevent_current = event.arg
                seeksteps_current = seeksteps
                seektime_current = int(time.time())
                seektime_delta = seektime_current - self.seektime_previous

                if (seektime_delta > 2) or (seekevent_current !=
                                            self.seekevent_previous):
                    # init/reset progressive seek mode
                    self.seeksteps = seeksteps
                    self.seektime_start = seektime_current
                    self.seektime_previous = seektime_current
                else:
                    # continue progressive seek mode
                    if ((seektime_delta > 0) and
                        ((seektime_delta %
                          config.XINE_TV_PROGRESSIVE_SEEK_THRESHOLD) == 0)):
                        self.seeksteps += config.XINE_TV_PROGRESSIVE_SEEK_INCREMENT
                        self.seektime_previous = seektime_current

                self.seekevent_previous = seekevent_current
                seeksteps = self.seeksteps

            # Note: Xine 2007 versions support
            # arbitrary SeekRelative+/- steps
            # limit seeksteps to [1 ; 120] seconds
            seeksteps = min(max(1, seeksteps), 120)

            self.xine.Seek(direction, seeksteps)
            return True

        if event == TOGGLE_OSD:
            self.tuner.ShowInfo()
            return True

        if event == OSD_MESSAGE:
            self.xine.ShowMessage(event.arg)
            return True