def getCableTransponderData(self, str): data = str.split() if len(data): if data[0] == 'OK': print str parm = eDVBFrontendParametersCable() qam = { "QAM16" : parm.Modulation_QAM16, "QAM32" : parm.Modulation_QAM32, "QAM64" : parm.Modulation_QAM64, "QAM128" : parm.Modulation_QAM128, "QAM256" : parm.Modulation_QAM256 } inv = { "INVERSION_OFF" : parm.Inversion_Off, "INVERSION_ON" : parm.Inversion_On, "INVERSION_AUTO" : parm.Inversion_Unknown } fec = { "FEC_AUTO" : parm.FEC_Auto, "FEC_1_2" : parm.FEC_1_2, "FEC_2_3" : parm.FEC_2_3, "FEC_3_4" : parm.FEC_3_4, "FEC_5_6": parm.FEC_5_6, "FEC_7_8" : parm.FEC_7_8, "FEC_8_9" : parm.FEC_8_9, "FEC_NONE" : parm.FEC_None } parm.frequency = int(data[1]) parm.symbol_rate = int(data[2]) parm.fec_inner = fec[data[3]] parm.modulation = qam[data[4]] parm.inversion = inv[data[5]] self.__tlist.append(parm) tmpstr = _("Try to find used Transponders in cable network.. please wait...") tmpstr += "\n\n" tmpstr += data[1] tmpstr += " kHz " tmpstr += data[0] self.cable_search_session["text"].setText(tmpstr)
def addCabTransponder(self, tlist, frequency, symbol_rate, modulation, fec, inversion): print "Add Cab: frequ: " + str(frequency) + " symbol: " + str(symbol_rate) + " pol: " + str(modulation) + " fec: " + str(fec) + " inversion: " + str(inversion) parm = eDVBFrontendParametersCable() parm.frequency = frequency * 1000 parm.symbol_rate = symbol_rate * 1000 parm.modulation = modulation parm.fec = fec parm.inversion = inversion tlist.append(parm)
def tuneCab(self, transponder): if self.frontend: print '[TuneTest] tuning to transponder with data', transponder parm = eDVBFrontendParametersCable() parm.frequency = transponder[0] parm.symbol_rate = transponder[1] parm.modulation = transponder[2] parm.fec_inner = transponder[3] parm.inversion = transponder[4] self.tuneCabObj(parm)
def tuneCab(self, transponder): if self.frontend: print "[TuneTest] tuning to transponder with data", transponder parm = eDVBFrontendParametersCable() parm.frequency = transponder[0] parm.symbol_rate = transponder[1] parm.modulation = transponder[2] parm.fec_inner = transponder[3] parm.inversion = transponder[4] #parm.system = transponder[5] self.tuneCabObj(parm)
def getInitialCableTransponderList(tlist, nim): list = nimmanager.getTranspondersCable(nim) for x in list: if x[0] == 1: #CABLE parm = eDVBFrontendParametersCable() parm.frequency = x[1] parm.symbol_rate = x[2] parm.modulation = x[3] parm.fec_inner = x[4] parm.inversion = x[5] parm.system = x[6] tlist.append(parm)
def getInitialCableTransponderList(tlist, nim): list = nimmanager.getTranspondersCable(nim) for x in list: if x[0] == 1: #CABLE parm = eDVBFrontendParametersCable() parm.frequency = x[1] parm.symbol_rate = x[2] parm.modulation = x[3] parm.fec_inner = x[4] parm.inversion = parm.Inversion_Unknown #print "frequency:", x[1] #print "symbol_rate:", x[2] #print "modulation:", x[3] #print "fec_inner:", x[4] #print "inversion:", 2 tlist.append(parm)
def getCableTransponderData(self, str): #prepend any remaining data from the previous call str = self.remainingdata + str #split in lines lines = str.split('\n') #'str' should end with '\n', so when splitting, the last line should be empty. If this is not the case, we received an incomplete line if len(lines[-1]): #remember this data for next time self.remainingdata = lines[-1] lines = lines[0:-1] else: self.remainingdata = "" for line in lines: data = line.split() if len(data): if data[0] == 'OK': print str parm = eDVBFrontendParametersCable() qam = { "QAM16" : parm.Modulation_QAM16, "QAM32" : parm.Modulation_QAM32, "QAM64" : parm.Modulation_QAM64, "QAM128" : parm.Modulation_QAM128, "QAM256" : parm.Modulation_QAM256 } inv = { "INVERSION_OFF" : parm.Inversion_Off, "INVERSION_ON" : parm.Inversion_On, "INVERSION_AUTO" : parm.Inversion_Unknown } fec = { "FEC_AUTO" : parm.FEC_Auto, "FEC_1_2" : parm.FEC_1_2, "FEC_2_3" : parm.FEC_2_3, "FEC_3_4" : parm.FEC_3_4, "FEC_5_6": parm.FEC_5_6, "FEC_7_8" : parm.FEC_7_8, "FEC_8_9" : parm.FEC_8_9, "FEC_NONE" : parm.FEC_None } parm.frequency = int(data[1]) parm.symbol_rate = int(data[2]) parm.fec_inner = fec[data[3]] parm.modulation = qam[data[4]] parm.inversion = inv[data[5]] self.__tlist.append(parm) tmpstr = _("Try to find used Transponders in cable network.. please wait...") tmpstr += "\n\n" tmpstr += data[1] tmpstr += " kHz " tmpstr += data[0] self.cable_search_session["text"].setText(tmpstr)
def getCableTransponderData(self, str): #prepend any remaining data from the previous call str = self.remainingdata + str #split in lines lines = str.split('\n') #'str' should end with '\n', so when splitting, the last line should be empty. If this is not the case, we received an incomplete line if len(lines[-1]): #remember this data for next time self.remainingdata = lines[-1] lines = lines[0:-1] else: self.remainingdata = "" for line in lines: data = line.split() if len(data): if data[0] == 'OK': print str parm = eDVBFrontendParametersCable() qam = { "QAM16" : parm.Modulation_QAM16, "QAM32" : parm.Modulation_QAM32, "QAM64" : parm.Modulation_QAM64, "QAM128" : parm.Modulation_QAM128, "QAM256" : parm.Modulation_QAM256 } inv = { "INVERSION_OFF" : parm.Inversion_Off, "INVERSION_ON" : parm.Inversion_On, "INVERSION_AUTO" : parm.Inversion_Unknown } fec = { "FEC_AUTO" : parm.FEC_Auto, "FEC_1_2" : parm.FEC_1_2, "FEC_2_3" : parm.FEC_2_3, "FEC_3_4" : parm.FEC_3_4, "FEC_5_6": parm.FEC_5_6, "FEC_7_8" : parm.FEC_7_8, "FEC_8_9" : parm.FEC_8_9, "FEC_NONE" : parm.FEC_None } parm.frequency = int(data[1]) parm.symbol_rate = int(data[2]) parm.fec_inner = fec[data[3]] parm.modulation = qam[data[4]] parm.inversion = inv[data[5]] self.__tlist.append(parm) tmpstr = _("Try to find used transponders in cable network.. please wait...") tmpstr += "\n\n" tmpstr += data[1] tmpstr += " kHz " tmpstr += data[0] self.cable_search_session["text"].setText(tmpstr)
def doTune(self): from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = config.autobouquetsmaker.providers.value.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print >> log, "[AutoBouquetsMaker] No area found" self.showError(_('No area found')) return transponder = self.providers[ self.currentAction]["bouquets"][bouquet_key] nimList = [] for nim in nimmanager.nim_slots: if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and ( (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S")) or (self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.isCompatible("DVB-C")) or (self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.isCompatible("DVB-T"))): nimList.append(nim.slot) if len(nimList) == 0: print >> log, "[AutoBouquetsMaker] No NIMs found" self.showError(_('No NIMs found')) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print >> log, "[AutoBouquetsMaker] Cannot retrieve Resource Manager instance" self.showError(_('Cannot retrieve Resource Manager instance')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": print >> log, "[AutoBouquetsMaker] Search NIM for orbital position %d" % transponder[ "orbital_position"] else: print >> log, "[AutoBouquetsMaker] Search NIM" # stop pip if running if self.session.pipshown: self.session.pipshown = False del self.session.pip print >> log, "[AutoBouquetsMaker] Stopping PIP." # stop currently playing service if it is using a tuner in ("loopthrough", "satposdepends") currentlyPlayingNIM = None currentService = self.session and self.session.nav.getCurrentService() frontendInfo = currentService and currentService.frontendInfo() frontendData = frontendInfo and frontendInfo.getAll(True) if frontendData is not None: currentlyPlayingNIM = frontendData.get("tuner_number", None) if self.providers[self.currentAction][ "streamtype"] == "dvbs" and currentlyPlayingNIM is not None: nimConfigMode = nimmanager.nim_slots[ currentlyPlayingNIM].config_mode if nimConfigMode in ("loopthrough", "satposdepends"): self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() currentlyPlayingNIM = None print >> log, "[AutoBouquetsMaker] The active service was using a %s tuner, so had to be stopped (slot id %s)." % ( nimConfigMode, currentlyPlayingNIM) del frontendInfo del currentService current_slotid = -1 if self.rawchannel: del (self.rawchannel) self.frontend = None self.rawchannel = None nimList.reverse() # start from the last for slotid in nimList: if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d with sat %s" % ( slotid, sat[1]) current_slotid = slotid break else: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d" % ( slotid) current_slotid = slotid break if self.rawchannel: break if current_slotid == -1: print >> log, "[AutoBouquetsMaker] No valid NIM found" self.showError(_('No valid NIM found')) return if not self.rawchannel: # if we are here the only possible option is to close the active service if currentlyPlayingNIM in nimList: slotid = currentlyPlayingNIM if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(currentlyPlayingNIM) for sat in sats: if sat[0] == transponder["orbital_position"]: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stopping active service" % currentlyPlayingNIM self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel( slotid) break else: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stopping active service" % currentlyPlayingNIM self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel(slotid) if not self.rawchannel: if self.session.nav.RecordTimer.isRecording(): print >> log, "[AutoBouquetsMaker] Cannot free NIM because a record is in progress" self.showError( _('Cannot free NIM because a recording is in progress') ) return else: print >> log, "[AutoBouquetsMaker] Cannot get the NIM" self.showError(_('Cannot get the NIM')) return # set extended timeout for rotors if self.providers[self.currentAction][ "streamtype"] == "dvbs" and self.isRotorSat( slotid, transponder["orbital_position"]): self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_ROTOR print >> log, "[AutoBouquetsMaker] Motorised dish. Will wait up to %i seconds for tuner lock." % ( self.LOCK_TIMEOUT / 10) else: self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_FIXED print >> log, "[AutoBouquetsMaker] Fixed dish. Will wait up to %i seconds for tuner lock." % ( self.LOCK_TIMEOUT / 10) self.frontend = self.rawchannel.getFrontend() if not self.frontend: print >> log, "[AutoBouquetsMaker] Cannot get frontend" self.showError(_('Cannot get frontend')) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print >> log, "[AutoBouquetsMaker] Cannot allocate the demuxer" self.showError(_('Cannot allocate the demuxer')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) self.rawchannel.requestTsidOnid() self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)
def doTune(self): from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = config.autobouquetsmaker.providers.value.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print >> log, "[AutoBouquetsMaker] No area found" self.showError(_("No area found")) return transponder = self.providers[self.currentAction]["bouquets"][bouquet_key] nimList = [] for nim in nimmanager.nim_slots: if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and ( (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S")) or (self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.isCompatible("DVB-C")) or (self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.isCompatible("DVB-T")) ): nimList.append(nim.slot) if len(nimList) == 0: print >> log, "[AutoBouquetsMaker] No NIMs found" self.showError(_("No NIMs found")) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print >> log, "[AutoBouquetsMaker] Cannot retrieve Resource Manager instance" self.showError(_("Cannot retrieve Resource Manager instance")) return if self.providers[self.currentAction]["streamtype"] == "dvbs": print >> log, "[AutoBouquetsMaker] Search NIM for orbital position %d" % transponder["orbital_position"] else: print >> log, "[AutoBouquetsMaker] Search NIM" # stop pip if running if self.session.pipshown: self.session.pipshown = False del self.session.pip print >> log, "[AutoBouquetsMaker] Stopping PIP." # stop currently playing service if it is using a tuner in ("loopthrough", "satposdepends") currentlyPlayingNIM = None currentService = self.session and self.session.nav.getCurrentService() frontendInfo = currentService and currentService.frontendInfo() frontendData = frontendInfo and frontendInfo.getAll(True) if frontendData is not None: currentlyPlayingNIM = frontendData.get("tuner_number", None) if self.providers[self.currentAction]["streamtype"] == "dvbs" and currentlyPlayingNIM is not None: nimConfigMode = nimmanager.nim_slots[currentlyPlayingNIM].config_mode if nimConfigMode in ("loopthrough", "satposdepends"): self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() currentlyPlayingNIM = None print >> log, "[AutoBouquetsMaker] The active service was using a %s tuner, so had to be stopped (slot id %s)." % ( nimConfigMode, currentlyPlayingNIM, ) del frontendInfo del currentService current_slotid = -1 if self.rawchannel: del (self.rawchannel) self.frontend = None self.rawchannel = None nimList.reverse() # start from the last for slotid in nimList: if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d with sat %s" % (slotid, sat[1]) current_slotid = slotid break else: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d" % (slotid) current_slotid = slotid break if self.rawchannel: break if current_slotid == -1: print >> log, "[AutoBouquetsMaker] No valid NIM found" self.showError(_("No valid NIM found")) return if not self.rawchannel: # if we are here the only possible option is to close the active service if currentlyPlayingNIM in nimList: slotid = currentlyPlayingNIM if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(currentlyPlayingNIM) for sat in sats: if sat[0] == transponder["orbital_position"]: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stopping active service" % currentlyPlayingNIM self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel(slotid) break else: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stopping active service" % currentlyPlayingNIM self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel(slotid) if not self.rawchannel: if self.session.nav.RecordTimer.isRecording(): print >> log, "[AutoBouquetsMaker] Cannot free NIM because a record is in progress" self.showError(_("Cannot free NIM because a recording is in progress")) return else: print >> log, "[AutoBouquetsMaker] Cannot get the NIM" self.showError(_("Cannot get the NIM")) return # set extended timeout for rotors if self.providers[self.currentAction]["streamtype"] == "dvbs" and self.isRotorSat( slotid, transponder["orbital_position"] ): self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_ROTOR print >> log, "[AutoBouquetsMaker] Motorised dish. Will wait up to %i seconds for tuner lock." % ( self.LOCK_TIMEOUT / 10 ) else: self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_FIXED print >> log, "[AutoBouquetsMaker] Fixed dish. Will wait up to %i seconds for tuner lock." % ( self.LOCK_TIMEOUT / 10 ) self.frontend = self.rawchannel.getFrontend() if not self.frontend: print >> log, "[AutoBouquetsMaker] Cannot get frontend" self.showError(_("Cannot get frontend")) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print >> log, "[AutoBouquetsMaker] Cannot allocate the demuxer" self.showError(_("Cannot allocate the demuxer")) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) self.rawchannel.requestTsidOnid() self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)
def doTune(self): from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = config.autobouquetsmaker.providers.value.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print>>log, "[AutoBouquetsMaker] No area found" self.showError(_('No area found')) return transponder = self.providers[self.currentAction]["bouquets"][bouquet_key] nimList = [] for nim in nimmanager.nim_slots: if (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S") and nim.config_mode not in ("loopthrough")) or (self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.isCompatible("DVB-C")) or (self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.isCompatible("DVB-T")): nimList.append(nim.slot) if len(nimList) == 0: print>>log, "[AutoBouquetsMaker] No NIMs found" self.showError(_('No NIMs found')) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print>>log, "[AutoBouquetsMaker] Cannot retrieve Resource Manager instance" self.showError(_('Cannot retrieve Resource Manager instance')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": print>>log, "[AutoBouquetsMaker] Search NIM for orbital position %d" % transponder["orbital_position"] else: print>>log, "[AutoBouquetsMaker] Search NIM" current_slotid = -1 if self.rawchannel: del(self.rawchannel) self.frontend = None self.rawchannel = None nimList.reverse() # start from the last for slotid in nimList: if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[AutoBouquetsMaker] Nim found on slot id %d with sat %s" % (slotid, sat[1]) current_slotid = slotid break else: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[AutoBouquetsMaker] Nim found on slot id %d" % (slotid) current_slotid = slotid break if self.rawchannel: break if current_slotid == -1: print>>log, "[AutoBouquetsMaker] No valid NIM found" self.showError(_('No valid NIM found')) return if not self.rawchannel: print>>log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stop current service" % current_slotid if self.session.nav.RecordTimer.isRecording(): print>>log, "[AutoBouquetsMaker] Cannot free NIM because a record is in progress" self.showError(_('Cannot free NIM because a record is in progress')) return self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() if self.session.pipshown: self.session.pipshown = False self.rawchannel = resmanager.allocateRawChannel(current_slotid) if not self.rawchannel: print>>log, "[AutoBouquetsMaker] Cannot get the NIM" self.showError(_('Cannot get the NIM')) return self.frontend = self.rawchannel.getFrontend() if not self.frontend: print>>log, "[AutoBouquetsMaker] Cannot get frontend" self.showError(_('Cannot get frontend')) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print>>log, "[AutoBouquetsMaker] Cannot allocate the demuxer" self.showError(_('Cannot allocate the demuxer')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) self.rawchannel.requestTsidOnid() self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)
def doTune(self): from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = config.autobouquetsmaker.providers.value.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print >> log, "[AutoBouquetsMaker] No area found" self.showError(_('No area found')) return transponder = self.providers[ self.currentAction]["bouquets"][bouquet_key] nimList = [] for nim in nimmanager.nim_slots: if (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S") and nim.config_mode not in ("loopthrough")) or ( self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.isCompatible("DVB-C")) or ( self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.isCompatible("DVB-T")): nimList.append(nim.slot) if len(nimList) == 0: print >> log, "[AutoBouquetsMaker] No NIMs found" self.showError(_('No NIMs found')) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print >> log, "[AutoBouquetsMaker] Cannot retrieve Resource Manager instance" self.showError(_('Cannot retrieve Resource Manager instance')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": print >> log, "[AutoBouquetsMaker] Search NIM for orbital position %d" % transponder[ "orbital_position"] else: print >> log, "[AutoBouquetsMaker] Search NIM" current_slotid = -1 if self.rawchannel: del (self.rawchannel) self.frontend = None self.rawchannel = None nimList.reverse() # start from the last for slotid in nimList: if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d with sat %s" % ( slotid, sat[1]) current_slotid = slotid break else: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d" % ( slotid) current_slotid = slotid break if self.rawchannel: break if current_slotid == -1: print >> log, "[AutoBouquetsMaker] No valid NIM found" self.showError(_('No valid NIM found')) return if not self.rawchannel: print >> log, "[AutoBouquetsMaker] Nim found on slot id %d but it's busy. Stop current service" % current_slotid if self.session.nav.RecordTimer.isRecording(): print >> log, "[AutoBouquetsMaker] Cannot free NIM because a record is in progress" self.showError( _('Cannot free NIM because a record is in progress')) return self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() if self.session.pipshown: self.session.pipshown = False self.rawchannel = resmanager.allocateRawChannel(current_slotid) if not self.rawchannel: print >> log, "[AutoBouquetsMaker] Cannot get the NIM" self.showError(_('Cannot get the NIM')) return self.frontend = self.rawchannel.getFrontend() if not self.frontend: print >> log, "[AutoBouquetsMaker] Cannot get frontend" self.showError(_('Cannot get frontend')) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print >> log, "[AutoBouquetsMaker] Cannot allocate the demuxer" self.showError(_('Cannot allocate the demuxer')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) self.rawchannel.requestTsidOnid() self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)
def doTune(self): print("[ABM-main][doTune] searching for tuner for %s" % self.providers[self.currentAction]["name"], file=log) from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = self.abm_settings_str.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print("[ABM-main][doTune] No area found", file=log) self.showError(_('No area found')) return transponder = self.providers[ self.currentAction]["bouquets"][bouquet_key] self.transponder = transponder nimList = [] tunerSelectionAlgorithm = "UNKNOWN" # for debug for nim in nimmanager.nim_slots: if self.providers[self.currentAction][ "streamtype"] == "dvbs" and nim.isCompatible("DVB-S"): try: if nim.isFBCLink(): continue # do not load FBC links, only root tuners except: pass try: # OpenPLi Hot Switch compatible image if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and \ {"dvbs": "DVB-S", "dvbc": "DVB-C", "dvbt": "DVB-T"}.get(self.providers[self.currentAction]["streamtype"], "UNKNOWN") in [x[:5] for x in nim.getTunerTypesEnabled()]: if self.validNIM(nim.slot): nimList.append(nim.slot) tunerSelectionAlgorithm = "OpenPLi Hot Switch compatible" except AttributeError: try: if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and \ ((self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S")) or (self.providers[self.currentAction]["streamtype"] == "dvbc" and (nim.isCompatible("DVB-C") or (nim.isCompatible("DVB-S") and nim.canBeCompatible("DVB-C")))) or (self.providers[self.currentAction]["streamtype"] == "dvbt" and (nim.isCompatible("DVB-T") or (nim.isCompatible("DVB-S") and nim.canBeCompatible("DVB-T"))))): if self.validNIM(nim.slot): nimList.append(nim.slot) tunerSelectionAlgorithm = "Conventional" except AttributeError: # OpenATV > 5.3 if (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.canBeCompatible("DVB-S") and nim.config_mode_dvbs not in ("loopthrough", "satposdepends", "nothing")) or \ (self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.canBeCompatible("DVB-C") and nim.config_mode_dvbc != "nothing") or \ (self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.canBeCompatible("DVB-T") and nim.config_mode_dvbt != "nothing"): if self.validNIM(nim.slot): nimList.append(nim.slot) tunerSelectionAlgorithm = "OpenATV > 5.3" print("[ABM-main][doTune] tuner selection algorithm '%s'" % tunerSelectionAlgorithm, file=log) if len(nimList) == 0: print("[ABM-main][doTune] No NIMs found", file=log) self.showError( _('No NIMs found for ') + self.providers[self.currentAction]["name"]) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print( "[ABM-main][doTune] Cannot retrieve Resource Manager instance", file=log) self.showError(_('Cannot retrieve Resource Manager instance')) return if self.providers[self.currentAction][ "streamtype"] == "dvbs": # If we have a choice of dishes sort the nimList so "fixed" dishes have a higher priority than "motorised". nimList = [ slot for slot in nimList if not self.isRotorSat(slot, transponder["orbital_position"]) ] + [ slot for slot in nimList if self.isRotorSat(slot, transponder["orbital_position"]) ] # stop pip if running if self.session.pipshown: self.session.pipshown = False del self.session.pip print("[ABM-main][doTune] Stopping PIP.", file=log) # find currently playing nim currentlyPlayingNIM = None currentService = self.session and self.session.nav.getCurrentService() frontendInfo = currentService and currentService.frontendInfo() frontendData = frontendInfo and frontendInfo.getAll(True) if frontendData is not None: currentlyPlayingNIM = frontendData.get("tuner_number", None) # stop currently playing service if it is using a tuner in ("loopthrough", "satposdepends"), as running in this configuration will prevent getting rawchannel on the root tuner. if self.providers[self.currentAction][ "streamtype"] == "dvbs" and currentlyPlayingNIM is not None and nimmanager.nim_slots[ currentlyPlayingNIM].isCompatible("DVB-S"): try: nimConfigMode = nimmanager.nim_slots[ currentlyPlayingNIM].config_mode except AttributeError: # OpenATV > 5.3 nimConfigMode = nimmanager.nim_slots[ currentlyPlayingNIM].config_mode_dvbs if nimConfigMode in ("loopthrough", "satposdepends"): self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() currentlyPlayingNIM = None print( "[ABM-main][doTune] The active service was using a %s tuner, so had to be stopped (slot id %s)." % (nimConfigMode, currentlyPlayingNIM), file=log) del frontendInfo del currentService self.releaseFrontend() for current_slotid in nimList: self.rawchannel = resmanager.allocateRawChannel(current_slotid) if self.rawchannel: print("[ABM-main][doTune] Tuner %s selected%s" % (chr(ord('A') + current_slotid), (" for orbital position %d" % transponder["orbital_position"] if "orbital_position" in transponder else "")), file=log) break if not self.rawchannel: # if we are here the only possible option is to close the active service if currentlyPlayingNIM in nimList: print( "[ABM-main][doTune] Tuner %s has been selected but it's busy. Stopping currently playing service." % chr(ord('A') + currentlyPlayingNIM), file=log) self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference( ) self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel( currentlyPlayingNIM) if self.rawchannel: print( "[ABM-main][doTune] The active service was stopped, and tuner %s is now free to use." % chr(ord('A') + currentlyPlayingNIM), file=log) current_slotid = currentlyPlayingNIM if not self.rawchannel: if self.session.nav.RecordTimer.isRecording(): print( "[ABM-main][doTune] Cannot free NIM because a recording is in progress", file=log) self.showError( _('Cannot free NIM because a recording is in progress') ) return else: print("[ABM-main][doTune] Cannot get the NIM", file=log) self.showError(_('Cannot get the NIM')) return # set extended timeout for rotors self.motorised = False if self.providers[self.currentAction][ "streamtype"] == "dvbs" and self.isRotorSat( current_slotid, transponder["orbital_position"]): self.motorised = True self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_ROTOR print( "[ABM-main][doTune] Motorised dish. Will wait up to %i seconds for tuner lock." % (self.LOCK_TIMEOUT // 10), file=log) else: self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_FIXED print( "[ABM-main][doTune] Fixed dish. Will wait up to %i seconds for tuner lock." % (self.LOCK_TIMEOUT // 10), file=log) if not inStandby: self["tuner_text"].setText(chr(ord('A') + current_slotid)) self.frontend = self.rawchannel.getFrontend() if not self.frontend: print("[ABM-main][doTune] Cannot get frontend", file=log) self.showError(_('Cannot get frontend')) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print("[ABM-main][doTune] Cannot allocate the demuxer.", file=log) self.showError(_('Cannot allocate the demuxer.')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] if hasattr(eDVBFrontendParametersSatellite, "No_Stream_Id_Filter"): params.is_id = eDVBFrontendParametersSatellite.No_Stream_Id_Filter if hasattr(eDVBFrontendParametersSatellite, "PLS_Gold"): params.pls_mode = eDVBFrontendParametersSatellite.PLS_Gold if hasattr(eDVBFrontendParametersSatellite, "PLS_Default_Gold_Code"): params.pls_code = eDVBFrontendParametersSatellite.PLS_Default_Gold_Code if hasattr(eDVBFrontendParametersSatellite, "No_T2MI_PLP_Id"): params.t2mi_plp_id = eDVBFrontendParametersSatellite.No_T2MI_PLP_Id if hasattr(eDVBFrontendParametersSatellite, "T2MI_Default_Pid"): params.t2mi_pid = eDVBFrontendParametersSatellite.T2MI_Default_Pid params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) try: self.rawchannel.requestTsidOnid() except TypeError: # for compatibility with some third party images self.rawchannel.requestTsidOnid(self.gotTsidOnid) self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.current_slotid = current_slotid self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)
def doTune(self): print>>log, "[ABM-main][doTune] searching for tuner for %s" % self.providers[self.currentAction]["name"] from Screens.Standby import inStandby if self.providers[self.currentAction]["streamtype"] == "dvbs": transponder = self.providers[self.currentAction]["transponder"] else: bouquet_key = None providers_tmp = self.abm_settings_str.split("|") for provider_tmp in providers_tmp: provider_config = ProviderConfig(provider_tmp) provider_key = provider_config.getProvider() if self.currentAction != provider_key: continue bouquet_key = provider_config.getArea() if not bouquet_key: print>>log, "[ABM-main][doTune] No area found" self.showError(_('No area found')) return transponder = self.providers[self.currentAction]["bouquets"][bouquet_key] nimList = [] for nim in nimmanager.nim_slots: if self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S"): try: if nim.isFBCTuner() and not nim.isFBCRoot(): continue # do not load FBC links, only root tuners except: pass try: # OpenPLi Hot Switch compatible image if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and \ {"dvbs": "DVB-S", "dvbc": "DVB-C", "dvbt": "DVB-T"}.get(self.providers[self.currentAction]["streamtype"], "UNKNOWN") in [x[:5] for x in nim.getTunerTypesEnabled()]: nimList.append(nim.slot) except AttributeError: try: if (nim.config_mode not in ("loopthrough", "satposdepends", "nothing")) and \ ((self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.isCompatible("DVB-S")) or \ (self.providers[self.currentAction]["streamtype"] == "dvbc" and (nim.isCompatible("DVB-C") or (nim.isCompatible("DVB-S") and nim.canBeCompatible("DVB-C")))) or \ (self.providers[self.currentAction]["streamtype"] == "dvbt" and (nim.isCompatible("DVB-T") or (nim.isCompatible("DVB-S") and nim.canBeCompatible("DVB-T"))))): nimList.append(nim.slot) except AttributeError: # OpenATV > 5.3 if (self.providers[self.currentAction]["streamtype"] == "dvbs" and nim.canBeCompatible("DVB-S") and nim.config_mode_dvbs not in ("loopthrough", "satposdepends", "nothing")) or \ (self.providers[self.currentAction]["streamtype"] == "dvbc" and nim.canBeCompatible("DVB-C") and nim.config_mode_dvbc != "nothing") or \ (self.providers[self.currentAction]["streamtype"] == "dvbt" and nim.canBeCompatible("DVB-T") and nim.config_mode_dvbt != "nothing"): nimList.append(nim.slot) if len(nimList) == 0: print>>log, "[ABM-main][doTune] No NIMs found" self.showError(_('No NIMs found for ') + self.providers[self.currentAction]["name"]) return resmanager = eDVBResourceManager.getInstance() if not resmanager: print>>log, "[ABM-main][doTune] Cannot retrieve Resource Manager instance" self.showError(_('Cannot retrieve Resource Manager instance')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": print>>log, "[ABM-main][doTune] Search NIM for orbital position %d" % transponder["orbital_position"] else: print>>log, "[ABM-main][doTune] Search NIM" # stop pip if running if self.session.pipshown: self.session.pipshown = False del self.session.pip print>>log, "[ABM-main][doTune] Stopping PIP." # stop currently playing service if it is using a tuner in ("loopthrough", "satposdepends") currentlyPlayingNIM = None currentService = self.session and self.session.nav.getCurrentService() frontendInfo = currentService and currentService.frontendInfo() frontendData = frontendInfo and frontendInfo.getAll(True) if frontendData is not None: currentlyPlayingNIM = frontendData.get("tuner_number", None) if self.providers[self.currentAction]["streamtype"] == "dvbs" and currentlyPlayingNIM is not None and nimmanager.nim_slots[currentlyPlayingNIM].isCompatible("DVB-S"): try: nimConfigMode = nimmanager.nim_slots[currentlyPlayingNIM].config_mode except AttributeError: # OpenATV > 5.3 nimConfigMode = nimmanager.nim_slots[currentlyPlayingNIM].config_mode_dvbs if nimConfigMode in ("loopthrough", "satposdepends"): self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() currentlyPlayingNIM = None print>>log, "[ABM-main][doTune] The active service was using a %s tuner, so had to be stopped (slot id %s)." % (nimConfigMode, currentlyPlayingNIM) del frontendInfo del currentService current_slotid = -1 if self.rawchannel: del(self.rawchannel) self.frontend = None self.rawchannel = None nimList.reverse() # start from the last for slotid in nimList: if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[ABM-main][doTune] Nim found on slot id %d with sat %s" % (slotid, sat[1]) current_slotid = slotid break else: if current_slotid == -1: # mark the first valid slotid in case of no other one is free current_slotid = slotid self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[ABM-main][doTune] Nim found on slot id %d" % (slotid) current_slotid = slotid break if self.rawchannel: break if current_slotid == -1: print>>log, "[ABM-main][doTune] No valid NIM found" self.showError(_('No valid NIM found for ') + self.providers[self.currentAction]["name"]) return if not self.rawchannel: # if we are here the only possible option is to close the active service if currentlyPlayingNIM in nimList: slotid = currentlyPlayingNIM if self.providers[self.currentAction]["streamtype"] == "dvbs": sats = nimmanager.getSatListForNim(slotid) for sat in sats: if sat[0] == transponder["orbital_position"]: print>>log, "[ABM-main][doTune] Nim found on slot id %d but it's busy. Stopping active service" % slotid self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[ABM-main][doTune] The active service was stopped, and the NIM is now free to use." current_slotid = slotid break else: print>>log, "[ABM-main][doTune] Nim found on slot id %d but it's busy. Stopping active service" % slotid self.postScanService = self.session.nav.getCurrentlyPlayingServiceReference() self.session.nav.stopService() self.rawchannel = resmanager.allocateRawChannel(slotid) if self.rawchannel: print>>log, "[ABM-main][doTune] The active service was stopped, and the NIM is now free to use." current_slotid = slotid if not self.rawchannel: if self.session.nav.RecordTimer.isRecording(): print>>log, "[ABM-main][doTune] Cannot free NIM because a recording is in progress" self.showError(_('Cannot free NIM because a recording is in progress')) return else: print>>log, "[ABM-main][doTune] Cannot get the NIM" self.showError(_('Cannot get the NIM')) return # set extended timeout for rotors self.motorised = False if self.providers[self.currentAction]["streamtype"] == "dvbs" and self.isRotorSat(current_slotid, transponder["orbital_position"]): self.motorised = True self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_ROTOR print>>log, "[ABM-main][doTune] Motorised dish. Will wait up to %i seconds for tuner lock." % (self.LOCK_TIMEOUT/10) else: self.LOCK_TIMEOUT = self.LOCK_TIMEOUT_FIXED print>>log, "[ABM-main][doTune] Fixed dish. Will wait up to %i seconds for tuner lock." % (self.LOCK_TIMEOUT/10) self.frontend = self.rawchannel.getFrontend() if not self.frontend: print>>log, "[ABM-main][doTune] Cannot get frontend" self.showError(_('Cannot get frontend')) return demuxer_id = self.rawchannel.reserveDemux() if demuxer_id < 0: print>>log, "[ABM-main][doTune] Cannot allocate the demuxer." self.showError(_('Cannot allocate the demuxer.')) return if self.providers[self.currentAction]["streamtype"] == "dvbs": params = eDVBFrontendParametersSatellite() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.polarisation = transponder["polarization"] params.fec = transponder["fec_inner"] params.inversion = transponder["inversion"] params.orbital_position = transponder["orbital_position"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.rolloff = transponder["roll_off"] params.pilot = transponder["pilot"] try: # if distro is MIS capable params.pls_mode = eDVBFrontendParametersSatellite.PLS_Root params.is_id = -1 params.pls_code = 1 except: pass params_fe = eDVBFrontendParameters() params_fe.setDVBS(params, False) elif self.providers[self.currentAction]["streamtype"] == "dvbt": params = eDVBFrontendParametersTerrestrial() params.frequency = transponder["frequency"] params.bandwidth = transponder["bandwidth"] params.code_rate_hp = transponder["code_rate_hp"] params.code_rate_lp = transponder["code_rate_lp"] params.inversion = transponder["inversion"] params.system = transponder["system"] params.modulation = transponder["modulation"] params.transmission_mode = transponder["transmission_mode"] params.guard_interval = transponder["guard_interval"] params.hierarchy = transponder["hierarchy"] params_fe = eDVBFrontendParameters() params_fe.setDVBT(params) elif self.providers[self.currentAction]["streamtype"] == "dvbc": params = eDVBFrontendParametersCable() params.frequency = transponder["frequency"] params.symbol_rate = transponder["symbol_rate"] params.fec_inner = transponder["fec_inner"] params.inversion = transponder["inversion"] params.modulation = transponder["modulation"] params_fe = eDVBFrontendParameters() params_fe.setDVBC(params) try: self.rawchannel.requestTsidOnid() except (TypeError): # for compatibility with some third party images self.rawchannel.requestTsidOnid(self.gotTsidOnid) self.frontend.tune(params_fe) self.manager.setAdapter(0) # FIX: use the correct device self.manager.setDemuxer(demuxer_id) self.manager.setFrontend(current_slotid) self.current_slotid = current_slotid self.lockcounter = 0 self.locktimer = eTimer() self.locktimer.callback.append(self.checkTunerLock) self.locktimer.start(100, 1)