コード例 #1
0
ファイル: core.py プロジェクト: pombredanne/kaa
def get_devices():
    global _devices
    if _devices is not None:
        return _devices
    _devices = {}
    for adapter in range(5):
        frontend = "/dev/dvb/adapter%s/frontend0" % adapter
        if not os.path.exists(frontend):
            continue
        # read frontend0 for aditional information
        INFO_ST = "128s10i"
        val = ioctl.pack(INFO_ST, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        devfd = os.open(frontend, os.O_TRUNC)
        r = ioctl.ioctl(devfd, ioctl.IOR("o", 61, INFO_ST), val)
        os.close(devfd)
        val = ioctl.unpack(INFO_ST, r)
        name = val[0].strip()
        if val[1] == 2:
            _devices["dvb%s" % adapter] = DVB_T(adapter)
    return _devices
コード例 #2
0
 def __init__(self, number):
     super(DVBCard, self).__init__('dvb', number)
     # get adapter based on number
     self.adapter = '/dev/dvb/adapter%s' % number
     # read frontend0 for aditional information
     INFO_ST = '128s10i'
     val = pack( INFO_ST, "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
     devfd = os.open(self.adapter + '/frontend0', os.O_TRUNC)
     r = ioctl(devfd, IOR('o', 61, INFO_ST), val)
     os.close(devfd)
     val = unpack( INFO_ST, r )
     name = val[0]
     if val[1] == 0:
         self.type = 'DVB-S'
         self._cfg_set_default('priority', 10)
     elif val[1] == 1:
         self.type = 'DVB-C'
         self._cfg_set_default('priority', 9)
     elif val[1] == 2:
         self.type = 'DVB-T'
         self._cfg_set_default('priority', 8)
     elif val[1] == 3:
         self.type = 'ATSC'
         self._cfg_set_default('priority', 7)
     else:
         # What is that?
         raise SystemError('unknown (%s)' % val[1])
     # special dvb config
     plugin = 'mplayer'
     if kaa.utils.which('dvbstreamer'):
         plugin = 'dvbstreamer'
     self._cfg_add(
         Var(name='plugin', default=plugin,
             desc='plugin to use for this device'))
     # fix name
     if name.find('\0') > 0:
         name = name[:name.find('\0')]
     self.name = name
     log.debug('register dvb device %s' % self.adapter)