示例#1
0
    def __init__(self, fd, dvb_parameters):
        self.fd = fd
        self.dvb_parameters = dvb_parameters

        self.params = linuxdvb.dvb_frontend_parameters()
        self.params.frequency = self.dvb_parameters.frequency
        self.params.u.ofdm.bandwidth = self.dvb_parameters.bandwidth
        self.params.u.ofdm.code_rate_HP = self.dvb_parameters.code_rate_HP
        self.params.u.ofdm.code_rate_LP = self.dvb_parameters.code_rate_LP
        self.params.inversion = self.dvb_parameters.inversion
        self.params.u.ofdm.constellation = self.dvb_parameters.constellation
        self.params.u.ofdm.transmission_mode = self.dvb_parameters.transmission_mode
        self.params.u.ofdm.guard_interval = self.dvb_parameters.guard_interval
        self.params.u.ofdm.hierarchy_information = self.dvb_parameters.hierarchy_information

        self.reset()
示例#2
0
	def __init__(self, fd, dvb_parameters):
		self.fd = fd
		self.dvb_parameters = dvb_parameters

		self.params = linuxdvb.dvb_frontend_parameters()
		self.params.frequency = self.dvb_parameters.frequency
		self.params.u.ofdm.bandwidth = self.dvb_parameters.bandwidth
		self.params.u.ofdm.code_rate_HP = self.dvb_parameters.code_rate_HP
		self.params.u.ofdm.code_rate_LP = self.dvb_parameters.code_rate_LP
		self.params.inversion = self.dvb_parameters.inversion
		self.params.u.ofdm.constellation = self.dvb_parameters.constellation
		self.params.u.ofdm.transmission_mode = self.dvb_parameters.transmission_mode
		self.params.u.ofdm.guard_interval = self.dvb_parameters.guard_interval
		self.params.u.ofdm.hierarchy_information = self.dvb_parameters.hierarchy_information
		
		self.reset()
示例#3
0
fefd = open('/dev/dvb/adapter0/frontend0', 'r+')
feinfo = linuxdvb.dvb_frontend_info()
fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)

print feinfo.name

'''
for bit, flag in linuxdvb.fe_caps.items():
     if (feinfo.caps & bit) > 0:
         print flag
'''
fefd.close()

fefd_ = open('/dev/dvb/adapter0/frontend0', 'w+')

params = linuxdvb.dvb_frontend_parameters()
params.frequency = 482 * 1000 * 1000
params.u.ofdm.bandwidth = linuxdvb.BANDWIDTH_8_MHZ
params.u.ofdm.code_rate_HP = linuxdvb.FEC_NONE
params.u.ofdm.code_rate_LP = linuxdvb.FEC_2_3
params.inversion = linuxdvb.INVERSION_AUTO
params.u.ofdm.constellation = linuxdvb.QAM_16
params.u.ofdm.transmission_mode = linuxdvb.TRANSMISSION_MODE_8K
params.u.ofdm.guard_interval = linuxdvb.GUARD_INTERVAL_1_8
params.u.ofdm.hierarchy_information = linuxdvb.HIERARCHY_NONE

fcntl.ioctl(fefd_, linuxdvb.FE_SET_FRONTEND, params)

params_ = linuxdvb.dvb_frontend_parameters()

status = linuxdvb.fe_status()
示例#4
0
fefd = open("/dev/dvb/adapter0/frontend0", "r+")
feinfo = linuxdvb.dvb_frontend_info()
fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)

print feinfo.name

"""
for bit, flag in linuxdvb.fe_caps.items():
     if (feinfo.caps & bit) > 0:
         print flag
"""
fefd.close()

fefd_ = open("/dev/dvb/adapter0/frontend0", "w+")

params = linuxdvb.dvb_frontend_parameters()
params.frequency = 482 * 1000 * 1000
params.u.ofdm.bandwidth = linuxdvb.BANDWIDTH_8_MHZ
params.u.ofdm.code_rate_HP = linuxdvb.FEC_NONE
params.u.ofdm.code_rate_LP = linuxdvb.FEC_2_3
params.inversion = linuxdvb.INVERSION_AUTO
params.u.ofdm.constellation = linuxdvb.QAM_16
params.u.ofdm.transmission_mode = linuxdvb.TRANSMISSION_MODE_8K
params.u.ofdm.guard_interval = linuxdvb.GUARD_INTERVAL_1_8
params.u.ofdm.hierarchy_information = linuxdvb.HIERARCHY_NONE

fcntl.ioctl(fefd_, linuxdvb.FE_SET_FRONTEND, params)

params_ = linuxdvb.dvb_frontend_parameters()

status = linuxdvb.fe_status()
示例#5
0
def loadConfig():

    global sock
    global mode
    global dvfd
    global dmfd
    global fefd

    config = ConfigParser.ConfigParser()
    config.read(sys.argv[1])

    mode = config.get('main', 'mode')

    if mode == 'ip':
        MCAST_GRP = config.get('main', 'source_ip')
        MCAST_PORT = config.getint('main', 'source_port')

        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM,
                             socket.IPPROTO_UDP)
        try:
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        except AttributeError:
            pass
        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32)
        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 1)
        #    sock.close()
        sock.bind((MCAST_GRP, MCAST_PORT))
        host = socket.gethostbyname(socket.gethostname())
        sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF,
                        socket.inet_aton(host))
        sock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
                        socket.inet_aton(MCAST_GRP) + socket.inet_aton(host))

        print 'Listening on ', MCAST_GRP, ':', MCAST_PORT

    if mode == 'dvb':
        print 'Mode DVB'
        adapter = '/dev/dvb/adapter0/'
        fefd = open(adapter + 'frontend0', 'r+')
        feinfo = linuxdvb.dvb_frontend_info()
        fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)
        print feinfo.name

        while True:

            # Tune
            pol = config.get('main', 'pol')
            if (pol == 'V') or (pol == 'v'):
                print 'volt', fcntl.ioctl(fefd, linuxdvb.FE_SET_VOLTAGE,
                                          linuxdvb.SEC_VOLTAGE_13)  #13 - V
            else:
                print 'volt', fcntl.ioctl(fefd, linuxdvb.FE_SET_VOLTAGE,
                                          linuxdvb.SEC_VOLTAGE_18)  #18 - V

            time.sleep(0.250)

            freq = config.getint('main', 'freq')

            if (freq > 11700):
                print 'tone', fcntl.ioctl(fefd, linuxdvb.FE_SET_TONE,
                                          linuxdvb.SEC_TONE_ON)  # ON - 11.7 hi
                loFreq = freq - 10600
            else:
                print 'tone', fcntl.ioctl(
                    fefd, linuxdvb.FE_SET_TONE,
                    linuxdvb.SEC_TONE_OFF)  # OFF - 11.7 hi
                loFreq = freq - 9750

            time.sleep(0.250)

            srate = config.getint('main', 'srate')

            #	dtv_prop = ctypes.POINTER(linuxdvb.dtv_property())
            dtv_prop = linuxdvb.dtv_property()
            dtv_prop.cmd = linuxdvb.DTV_DELIVERY_SYSTEM
            dtv_prop.u.data = linuxdvb.SYS_DVBS2

            dtv_props = linuxdvb.dtv_properties()
            dtv_props.num = 1
            #	dtv_props.props = ctypes.POINTER(dtv_prop)
            #	dtv_props.props = ctypes.cast(dtv_prop, ctypes.POINTER(ctypes.Structure))
            dtv_props.props = ctypes.pointer(dtv_prop)
            print 'props', fcntl.ioctl(fefd, linuxdvb.FE_SET_PROPERTY,
                                       dtv_props)

            params = linuxdvb.dvb_frontend_parameters()
            params.frequency = loFreq * 1000
            params.inversion = linuxdvb.INVERSION_AUTO
            params.u.qpsk.symbol_rate = srate * 1000
            params.u.qpsk.fec_inner = linuxdvb.FEC_AUTO
            print 'front', fcntl.ioctl(fefd, linuxdvb.FE_SET_FRONTEND, params)

            fcntl.ioctl(fefd, linuxdvb.FE_GET_FRONTEND, params)
            print params.u.qpsk.fec_inner

            festatus = linuxdvb.dvb_frontend_event()
            fcntl.ioctl(fefd, linuxdvb.FE_READ_STATUS, festatus)
            if festatus.status & 0x10:
                print "FE_HAS_LOCK"
                break
            else:
                print "No lock!"

        dmfd = open(adapter + 'demux0', 'r+')

        # Pes stream
        pesfilter = linuxdvb.dmx_pes_filter_params()
        pesfilter.pid = 8192
        pesfilter.input = linuxdvb.DMX_IN_FRONTEND
        pesfilter.output = linuxdvb.DMX_OUT_TS_TAP
        pesfilter.pes_type = linuxdvb.DMX_PES_OTHER
        pesfilter.flags = linuxdvb.DMX_IMMEDIATE_START
        fcntl.ioctl(dmfd, linuxdvb.DMX_SET_PES_FILTER, pesfilter)

        dvfd = open(adapter + 'dvr0', 'r')


#	while True:
#	    fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)
#	    print feinfo.frequency
#	    packet = dvr.read(188)
#	    print len(packet)

    newDSTs = {}

    config = ConfigParser.ConfigParser()
    config.read(sys.argv[1])

    for section in config.sections():
        if section != 'main':
            newDSTs[section] = config.getint(section, 'sid')

    global DSTs
    DSTs = newDSTs

    for IP in DSTs:
        datas[IP] = ""
        IP_PID[IP] = []
示例#6
0
def loadConfig():

    global sock
    global mode
    global dvfd
    global dmfd
    global fefd

    config = ConfigParser.ConfigParser()
    config.read(sys.argv[1])

    mode = config.get('main', 'mode')
    
    if mode == 'ip':
        MCAST_GRP = config.get('main','source_ip')
        MCAST_PORT = config.getint('main','source_port')

    
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        try:
          sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        except AttributeError:
           pass
        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 32) 
        sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 1)
    #    sock.close()
        sock.bind((MCAST_GRP, MCAST_PORT))
        host = socket.gethostbyname(socket.gethostname())
        sock.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(host))
        sock.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(MCAST_GRP) + socket.inet_aton(host))

	print 'Listening on ',MCAST_GRP,':',MCAST_PORT

    if mode == 'dvb':
	print 'Mode DVB'
	adapter = '/dev/dvb/adapter0/'
	fefd = open(adapter + 'frontend0', 'r+') 
	feinfo = linuxdvb.dvb_frontend_info() 
	fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)
	print feinfo.name


	while True:

		# Tune
		pol = config.get('main','pol')
		if (pol == 'V') or (pol == 'v'):
			print 'volt', fcntl.ioctl(fefd, linuxdvb.FE_SET_VOLTAGE, linuxdvb.SEC_VOLTAGE_13) #13 - V
		else:
			print 'volt', fcntl.ioctl(fefd, linuxdvb.FE_SET_VOLTAGE, linuxdvb.SEC_VOLTAGE_18) #18 - V
	
		time.sleep(0.250)
	
		freq = config.getint('main','freq')
	
		if (freq > 11700):
			print 'tone', fcntl.ioctl(fefd, linuxdvb.FE_SET_TONE, linuxdvb.SEC_TONE_ON) # ON - 11.7 hi
			loFreq = freq - 10600
		else:
			print 'tone', fcntl.ioctl(fefd, linuxdvb.FE_SET_TONE, linuxdvb.SEC_TONE_OFF) # OFF - 11.7 hi
			loFreq = freq - 9750
	
		time.sleep(0.250)
	
		srate = config.getint('main','srate')
	
	#	dtv_prop = ctypes.POINTER(linuxdvb.dtv_property())
		dtv_prop = linuxdvb.dtv_property()
		dtv_prop.cmd = linuxdvb.DTV_DELIVERY_SYSTEM
		dtv_prop.u.data = linuxdvb.SYS_DVBS2
	
		dtv_props = linuxdvb.dtv_properties()
		dtv_props.num = 1
	#	dtv_props.props = ctypes.POINTER(dtv_prop)
	#	dtv_props.props = ctypes.cast(dtv_prop, ctypes.POINTER(ctypes.Structure))
		dtv_props.props = ctypes.pointer(dtv_prop)
		print 'props', fcntl.ioctl(fefd, linuxdvb.FE_SET_PROPERTY, dtv_props)
	
		params = linuxdvb.dvb_frontend_parameters()
		params.frequency = loFreq * 1000
		params.inversion = linuxdvb.INVERSION_AUTO
		params.u.qpsk.symbol_rate = srate * 1000
		params.u.qpsk.fec_inner = linuxdvb.FEC_AUTO
		print 'front', fcntl.ioctl(fefd, linuxdvb.FE_SET_FRONTEND, params)
	
		fcntl.ioctl(fefd, linuxdvb.FE_GET_FRONTEND, params)
		print params.u.qpsk.fec_inner

		festatus = linuxdvb.dvb_frontend_event()
		fcntl.ioctl(fefd, linuxdvb.FE_READ_STATUS, festatus)
		if festatus.status & 0x10:
			print "FE_HAS_LOCK"
			break
		else:
			print "No lock!"

	dmfd = open(adapter + 'demux0', 'r+')

	# Pes stream
	pesfilter = linuxdvb.dmx_pes_filter_params()
	pesfilter.pid = 8192
	pesfilter.input = linuxdvb.DMX_IN_FRONTEND
	pesfilter.output = linuxdvb.DMX_OUT_TS_TAP
	pesfilter.pes_type = linuxdvb.DMX_PES_OTHER
	pesfilter.flags = linuxdvb.DMX_IMMEDIATE_START
	fcntl.ioctl(dmfd, linuxdvb.DMX_SET_PES_FILTER, pesfilter)

	dvfd = open(adapter + 'dvr0', 'r')

#	while True:
#	    fcntl.ioctl(fefd, linuxdvb.FE_GET_INFO, feinfo)
#	    print feinfo.frequency
#	    packet = dvr.read(188)
#	    print len(packet)
 
    newDSTs = {}

    config = ConfigParser.ConfigParser()
    config.read(sys.argv[1])

    for section in config.sections():
	if section != 'main':
	    newDSTs[section]=config.getint(section, 'sid')

    global DSTs
    DSTs = newDSTs

    for IP in DSTs:
        datas[IP] = ""
	IP_PID[IP] = []