def confirm(self, confirmed): if not confirmed: if self.reset_mode == 1: config.av.videoport.setValue(self.last_good[0]) config.av.videomode[self.last_good[0]].setValue(self.last_good[1]) config.av.videorate[self.last_good[1]].setValue(self.last_good[2]) config.av.autores_sd.setValue(self.last_good_extra[0]) config.av.smart1080p.setValue(self.last_good_extra[1]) self.hw.setMode(*self.last_good) elif self.reset_mode == 2: config.av.autores_mode_sd[self.last_good_autores_sd[0]].setValue(self.last_good_autores_sd[1]) config.av.autores_rate_sd[self.last_good_autores_sd[1]].setValue(self.last_good_autores_sd[2]) config.av.autores_mode_hd[self.last_good_autores_hd[0]].setValue(self.last_good_autores_hd[1]) config.av.autores_rate_hd[self.last_good_autores_hd[1]].setValue(self.last_good_autores_hd[2]) config.av.autores_mode_fhd[self.last_good_autores_fhd[0]].setValue(self.last_good_autores_fhd[1]) config.av.autores_rate_fhd[self.last_good_autores_fhd[1]].setValue(self.last_good_autores_fhd[2]) config.av.autores_mode_uhd[self.last_good_autores_uhd[0]].setValue(self.last_good_autores_uhd[1]) config.av.autores_rate_uhd[self.last_good_autores_uhd[1]].setValue(self.last_good_autores_uhd[2]) config.av.autores_24p.setValue(self.last_good_autores_extra[0]) config.av.autores_1080i_deinterlace.setValue(self.last_good_autores_extra[1]) config.av.autores_unknownres.setValue(self.last_good_autores_unknownres) try: if not self.current_mode in iAVSwitch.readAvailableModes(): raise TypeError("No old video mode saved!") f = open("/proc/stb/video/videomode", "w") f.write(self.current_mode) f.close() except Exception as e: print("[VideoMode] failed to set old video mode!", e) self.hw.setMode(*self.last_good) self.createSetup() else: self.keySave()
def createSetup(self): level = config.usage.setup_level.index self.list = [ getConfigListEntry( _("Video output"), config.av.videoport, _("Configures which video output connector will be used.")) ] if config.av.videoport.value in ('HDMI', 'YPbPr', 'Scart-YPbPr') and not path.exists( resolveFilename(SCOPE_PLUGINS) + 'SystemPlugins/AutoResolution'): self.list.append( getConfigListEntry( _("Automatic resolution"), config.av.autores, _("If enabled the output resolution of the box will try to match the resolution of the video content" ))) if config.av.autores.value in ('all', 'hd'): self.list.append( getConfigListEntry( _("Force de-interlace"), config.av.autores_deinterlace, _("If enabled the video will always be de-interlaced.") )) self.list.append( getConfigListEntry( _("Automatic resolution label"), config.av.autores_label_timeout, _("Allows you to adjust the amount of time the resolution infomation display on screen." ))) if config.av.autores.value in ('hd'): self.list.append( getConfigListEntry( _("Show SD as"), config.av.autores_sd, _("This option allows you to choose how to display standard defintion video on your TV." ))) self.list.append( getConfigListEntry( _("Show 480/576p 24fps as"), config.av.autores_480p24, _("This option allows you to choose how to display SD progressive 24Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 720p 24fps as"), config.av.autores_720p24, _("This option allows you to choose how to display 720p 24Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 1080p 24fps as"), config.av.autores_1080p24, _("This option allows you to choose how to display 1080p 24Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 1080p 25fps as"), config.av.autores_1080p25, _("This option allows you to choose how to display 1080p 25Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 1080p 30fps as"), config.av.autores_1080p30, _("This option allows you to choose how to display 1080p 30Hz on your TV. (as not all TVs support these resolutions)" ))) if '2160p24' in iAVSwitch.readAvailableModes(): self.list.append( getConfigListEntry( _("Show 2160p 24fps as"), config.av.autores_2160p24, _("This option allows you to choose how to display 2160p 24Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 2160p 25fps as"), config.av.autores_2160p25, _("This option allows you to choose how to display 2160p 25Hz on your TV. (as not all TVs support these resolutions)" ))) self.list.append( getConfigListEntry( _("Show 2160p 30fps as"), config.av.autores_2160p30, _("This option allows you to choose how to display 2160p 30Hz on your TV. (as not all TVs support these resolutions)" ))) # if we have modes for this port: if (config.av.videoport.value in config.av.videomode and config.av.autores.value == 'disabled') or config.av.videoport.value == 'Scart': # add mode- and rate-selection: self.list.append( getConfigListEntry( pgettext("Video output mode", "Mode"), config.av.videomode[config.av.videoport.value], _("This option configures the video output mode (or resolution)." ))) if config.av.videomode[config.av.videoport.value].value == 'PC': self.list.append( getConfigListEntry( _("Resolution"), config.av.videorate[config.av.videomode[ config.av.videoport.value].value], _("This option configures the screen resolution in PC output mode." ))) elif config.av.videoport.value != 'Scart': self.list.append( getConfigListEntry( _("Refresh rate"), config.av.videorate[config.av.videomode[ config.av.videoport.value].value], _("Configure the refresh rate of the screen. Multi means refresh rate depends on the source 24/50/60Hz" ))) if config.av.autores.value in ( 'all', 'hd') or config.av.videorate[config.av.videomode[ config.av.videoport.value].value].value == 'multi': self.list.append( getConfigListEntry( _("Delay time"), config.av.autores_delay, _("Set the time before checking video source for resolution/refresh rate infomation." ))) port = config.av.videoport.value if port not in config.av.videomode: mode = None else: mode = config.av.videomode[port].value # some modes (720p, 1080i) are always widescreen. Don't let the user select something here, "auto" is not what he wants. force_wide = self.hw.isWidescreenMode(port, mode) # if not force_wide: # self.list.append(getConfigListEntry(_("Aspect ratio"), config.av.aspect, _("Configure the aspect ratio of the screen."))) if force_wide or config.av.aspect.value in ("16:9", "16:10"): self.list.extend(( getConfigListEntry( _("Display 4:3 content as"), config.av.policy_43, _("When the content has an aspect ratio of 4:3, choose whether to scale/stretch the picture." )), getConfigListEntry( _("Display >16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture." )))) elif config.av.aspect.value == "4:3": self.list.append( getConfigListEntry( _("Display 16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture." ))) if config.av.videoport.value == "Scart": self.list.append( getConfigListEntry( _("Color format"), config.av.colorformat, _("Configure which color format should be used on the SCART output." ))) if level >= 1: self.list.append( getConfigListEntry( _("WSS on 4:3"), config.av.wss, _("When enabled, content with an aspect ratio of 4:3 will be stretched to fit the screen." ))) if SystemInfo["ScartSwitch"]: self.list.append( getConfigListEntry( _("Auto scart switching"), config.av.vcrswitch, _("When enabled, your receiver will detect activity on the VCR SCART input." ))) if SystemInfo["havecolorspace"]: self.list.append( getConfigListEntry( _("HDMI Colorspace"), config.av.hdmicolorspace, _("Change the Colorspace from Auto to RGB"))) if SystemInfo["havecolorimetry"]: self.list.append( getConfigListEntry(_("HDMI Colorimetry"), config.av.hdmicolorimetry, _("Change the Colorimetry for HDR"))) if SystemInfo["havehdmicolordepth"]: self.list.append( getConfigListEntry(_("HDMI Colordepth"), config.av.hdmicolordepth, _("Change the Colordepth for UHD"))) if SystemInfo["havehdmihdrtype"]: self.list.append( getConfigListEntry( _("HDMI HDR Type"), config.av.hdmihdrtype, _("Enable or disable to force HDR Modes for UHD"))) if SystemInfo["HDRSupport"]: self.list.append( getConfigListEntry( _("HLG Support"), config.av.hlg_support, _("Enable or disable to force HLG Modes for UHD"))) self.list.append( getConfigListEntry( _("HDR10 Support"), config.av.hdr10_support, _("Enable or disable to force HDR10 Modes for UHD"))) self.list.append( getConfigListEntry( _("Allow 12bit"), config.av.allow_12bit, _("Enable or disable the 12 Bit Color Mode"))) self.list.append( getConfigListEntry( _("Allow 10bit"), config.av.allow_10bit, _("Enable or disable the 10 Bit Color Mode"))) if level >= 1: if SystemInfo["CanDownmixAC3"]: self.list.append( getConfigListEntry( _("AC3 downmix"), config.av.downmix_ac3, _("Choose whether multi channel ac3 sound tracks should be downmixed to stereo." ))) if SystemInfo["CanDownmixDTS"]: self.list.append( getConfigListEntry( _("DTS downmix"), config.av.downmix_dts, _("Choose whether multi channel dts sound tracks should be downmixed to stereo." ))) if SystemInfo["CanDownmixAACPlus"]: self.list.append( getConfigListEntry( _("AAC+ downmix"), config.av.downmix_aacplus, _("Choose whether multi channel aac+ sound tracks should be downmixed to stereo." ))) elif SystemInfo["CanDownmixAAC"]: self.list.append( getConfigListEntry( _("AAC downmix"), config.av.downmix_aac, _("Choose whether multi channel aac sound tracks should be downmixed to stereo." ))) if SystemInfo["CanAC3Transcode"]: self.list.append( getConfigListEntry(_("AC3 transcoding"), config.av.transcodeac3plus, None)) if SystemInfo["CanAACTranscode"]: self.list.append( getConfigListEntry( _("AAC transcoding"), config.av.transcodeaac, _("Choose whether AAC sound tracks should be transcoded." ))) if SystemInfo["CanDTSHD"]: self.list.append( getConfigListEntry( _("DTS-HD HR/DTS-HD MA/DTS"), config.av.dtshd, ("Choose whether multi channel DTSHD sound tracks should be downmixed or transcoded.." ))) if SystemInfo["CanWMAPRO"]: self.list.append( getConfigListEntry( _("WMA Pro downmix"), config.av.wmapro, _("Choose whether WMA Pro sound tracks should be downmixed." ))) if SystemInfo["CanPcmMultichannel"]: self.list.append( getConfigListEntry( _("PCM Multichannel"), config.av.pcm_multichannel, _("Choose whether multi channel sound tracks should be output as PCM." ))) self.list.extend(( getConfigListEntry( _("General AC3 delay"), config.av.generalAC3delay, _("This option configures the general audio delay of Dolby Digital sound tracks." )), getConfigListEntry( _("General PCM delay"), config.av.generalPCMdelay, _("This option configures the general audio delay of stereo sound tracks." )))) if SystemInfo["CanBTAudio"]: self.list.append( getConfigListEntry( _("Enable Bluetooth Audio"), config.av.btaudio, _("This Option allows you to switch audio to bluetooth speakers." ))) if SystemInfo["CanBTAudioDelay"]: self.list.append( getConfigListEntry( _("General Bluetooth Audio delay"), config.av.btaudiodelay, _("This option configures the general audio delay for bluetooth speakers." ))) if SystemInfo["Can3DSurround"]: self.list.append( getConfigListEntry( _("3D Surround"), config.av.surround_3d, _("This option allows you to enable 3D Surround Sound for an output." ))) if SystemInfo[ "Can3DSpeaker"] and config.av.surround_3d.value != "none": self.list.append( getConfigListEntry( _("3D Surround Speaker Position"), config.av.surround_3d_speaker, _("This option allows you to change the virtual loudspeaker position." ))) if SystemInfo["CanAutoVolume"]: self.list.append( getConfigListEntry( _("Auto Volume Level"), config.av.autovolume, _("This option configures output for Auto Volume Level." ))) if SystemInfo["Canedidchecking"]: self.list.append( getConfigListEntry( _("Bypass HDMI EDID Check"), config.av.bypass_edid_checking, _("This option allows you to bypass HDMI EDID check"))) if SystemInfo["haveboxmode"]: self.list.append( getConfigListEntry( _("Video Chip Mode*"), config.av.boxmode, _("Choose between High Dynamic Range (HDR) or Picture in Picture (PIP). Both are not possible at the same time. A FULL REBOOT is required for it to take effect" ))) # if not isinstance(config.av.scaler_sharpness, ConfigNothing): # self.list.append(getConfigListEntry(_("Scaler sharpness"), config.av.scaler_sharpness, _("This option configures the picture sharpness."))) self["config"].list = self.list self["config"].l.setList(self.list) if config.usage.sort_settings.value: self["config"].list.sort()
def VideoChangeDetect(self): global resolutionlabel config_port = config.av.videoport.value config_mode = str(config.av.videomode[config_port].value).replace( '\n', '') config_res = str(config.av.videomode[config_port].value[:-1]).replace( '\n', '') config_pol = str(config.av.videomode[config_port].value[-1:]).replace( '\n', '') config_rate = str(config.av.videorate[config_mode].value).replace( 'Hz', '').replace('\n', '') f = open("/proc/stb/video/videomode") current_mode = f.read()[:-1].replace('\n', '') f.close() if current_mode.upper() in ('PAL', 'NTSC'): current_mode = current_mode.upper() current_pol = '' if 'i' in current_mode: current_pol = 'i' elif 'p' in current_mode: current_pol = 'p' current_res = current_pol and current_mode.split( current_pol)[0].replace('\n', '') or "" current_rate = current_pol and current_mode.split( current_pol)[0].replace( '\n', '') and current_mode.split(current_pol)[1].replace( '\n', '') or "" video_height = None video_width = None video_pol = None video_rate = None if path.exists("/proc/stb/vmpeg/0/yres"): f = open("/proc/stb/vmpeg/0/yres", "r") try: video_height = int(f.read(), 16) except: pass f.close() if path.exists("/proc/stb/vmpeg/0/xres"): f = open("/proc/stb/vmpeg/0/xres", "r") try: video_width = int(f.read(), 16) except: pass f.close() if path.exists("/proc/stb/vmpeg/0/progressive"): f = open("/proc/stb/vmpeg/0/progressive", "r") try: video_pol = "p" if int(f.read(), 16) else "i" except: pass f.close() if path.exists("/proc/stb/vmpeg/0/framerate"): f = open("/proc/stb/vmpeg/0/framerate", "r") try: video_rate = int(f.read()) except: pass f.close() if not video_height or not video_width or not video_pol or not video_rate: service = self.session.nav.getCurrentService() if service is not None: info = service.info() else: info = None if info: video_height = int( info.getInfo(iServiceInformation.sVideoHeight)) video_width = int(info.getInfo( iServiceInformation.sVideoWidth)) video_pol = ("i", "p")[info.getInfo( iServiceInformation.sProgressive)] video_rate = int(info.getInfo(iServiceInformation.sFrameRate)) if video_height and video_width and video_pol and video_rate: resolutionlabel["content"].setText( _("Video content: %ix%i%s %iHz") % (video_width, video_height, video_pol, (video_rate + 500) / 1000)) if (1 < video_width <= 1024) and video_height <= 480 and video_rate in ( 23976, 24000, 25000, 29970, 50000, 59940): new_res = "480" elif (1 < video_width <= 1024 ) and video_height <= 576 and video_rate in (23976, 24000, 25000, 50000): new_res = "576" elif (video_width == 1280) and video_height <= 720: new_res = "720" elif (video_width == 1920) and video_height <= 1080: new_res = "1080" elif (video_width == 3840) and video_height > 1080: new_res = "2160" else: new_res = config_res if video_rate != -1: if video_rate == 25000 and video_pol == 'i': new_rate = 50000 elif video_rate == 59940 or ( video_rate == 29970 and video_pol == 'i') or (video_rate == 29970 and video_pol == 'p' and config.av.autores.value == 'disabled'): new_rate = 60000 elif video_rate == 23976: new_rate = 24000 elif video_rate == 29970: new_rate = 30000 else: new_rate = video_rate new_rate = str((new_rate + 500) / 1000) else: new_rate = config_rate if video_pol != -1: new_pol = str(video_pol) else: new_pol = config_pol write_mode = None new_mode = None if config_mode in ('PAL', 'NTSC'): write_mode = config_mode elif config.av.autores.value == 'all' or ( config.av.autores.value == 'hd' and int(new_res) >= 720): if (config.av.autores_deinterlace.value and HardwareInfo().is_nextgen()) or ( config.av.autores_deinterlace.value and not HardwareInfo().is_nextgen() and int(new_res) <= 720): new_pol = new_pol.replace('i', 'p') if new_res + new_pol + new_rate in iAVSwitch.readAvailableModes( ): new_mode = new_res + new_pol + new_rate if new_mode == '480p24' or new_mode == '576p24': new_mode = config.av.autores_480p24.value if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25' or new_mode == '2160p50': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value elif new_res + new_pol in iAVSwitch.readAvailableModes(): new_mode = new_res + new_pol if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value else: new_mode = config_mode + new_rate write_mode = new_mode elif config.av.autores.value == 'hd' and int(new_res) <= 576: if (config.av.autores_deinterlace.value and HardwareInfo().is_nextgen()) or ( config.av.autores_deinterlace.value and not HardwareInfo().is_nextgen() and not config.av.autores_sd.value == '1080i'): new_mode = config.av.autores_sd.value.replace( 'i', 'p') + new_rate else: if new_pol in 'p': new_mode = config.av.autores_sd.value.replace( 'i', 'p') + new_rate else: new_mode = config.av.autores_sd.value + new_rate if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30': new_mode = config.av.autores_2160p30.value write_mode = new_mode else: if path.exists('/proc/stb/video/videomode_%shz' % new_rate) and config_rate == 'multi': try: f = open("/proc/stb/video/videomode_%shz" % new_rate, "r") multi_videomode = f.read().replace('\n', '') f.close() if multi_videomode and (current_mode != multi_videomode): write_mode = multi_videomode else: write_mode = current_mode except IOError: write_mode = current_mode if write_mode and current_mode != write_mode: resolutionlabel["restxt"].setText( _("Video mode: %s") % write_mode) if config.av.autores.value != "disabled" and config.av.autores_label_timeout.value != '0': resolutionlabel.show() print "[VideoMode] setMode - port: %s, mode: %s" % ( config_port, write_mode) f = open("/proc/stb/video/videomode", "w") f.write(write_mode) f.close() iAVSwitch.setAspect(config.av.aspect) iAVSwitch.setWss(config.av.wss) iAVSwitch.setPolicy43(config.av.policy_43) iAVSwitch.setPolicy169(config.av.policy_169) self.delay = False self.detecttimer.stop()
def createSetup(self): level = config.usage.setup_level.index self.list = [ getConfigListEntry(_("Video output"), config.av.videoport, _("Configures which video output connector will be used.")) ] if config.av.videoport.value in ('HDMI', 'YPbPr', 'Scart-YPbPr') and not path.exists(resolveFilename(SCOPE_PLUGINS)+'SystemPlugins/AutoResolution'): self.list.append(getConfigListEntry(_("Automatic resolution"), config.av.autores,_("If enabled the output resolution of the box will try to match the resolution of the video content"))) if config.av.autores.value in ('all', 'hd'): self.list.append(getConfigListEntry(_("Force de-interlace"), config.av.autores_deinterlace,_("If enabled the video will always be de-interlaced."))) self.list.append(getConfigListEntry(_("Automatic resolution label"), config.av.autores_label_timeout,_("Allows you to adjust the amount of time the resolution infomation display on screen."))) if config.av.autores.value in ('hd'): self.list.append(getConfigListEntry(_("Show SD as"), config.av.autores_sd,_("This option allows you to choose how to display standard defintion video on your TV."))) self.list.append(getConfigListEntry(_("Show 480/576p 24fps as"), config.av.autores_480p24,_("This option allows you to choose how to display SD progressive 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 720p 24fps as"), config.av.autores_720p24,_("This option allows you to choose how to display 720p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 24fps as"), config.av.autores_1080p24,_("This option allows you to choose how to display 1080p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 25fps as"), config.av.autores_1080p25,_("This option allows you to choose how to display 1080p 25Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 30fps as"), config.av.autores_1080p30,_("This option allows you to choose how to display 1080p 30Hz on your TV. (as not all TV's support these resolutions)"))) if '2160p24' in iAVSwitch.readAvailableModes(): self.list.append(getConfigListEntry(_("Show 2160p 24fps as"), config.av.autores_2160p24,_("This option allows you to choose how to display 2160p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 2160p 25fps as"), config.av.autores_2160p25,_("This option allows you to choose how to display 2160p 25Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 2160p 30fps as"), config.av.autores_2160p30,_("This option allows you to choose how to display 2160p 30Hz on your TV. (as not all TV's support these resolutions)"))) # if we have modes for this port: if (config.av.videoport.value in config.av.videomode and config.av.autores.value == 'disabled') or config.av.videoport.value == 'Scart': # add mode- and rate-selection: self.list.append(getConfigListEntry(pgettext("Video output mode", "Mode"), config.av.videomode[config.av.videoport.value], _("This option configures the video output mode (or resolution)."))) if config.av.videomode[config.av.videoport.value].value == 'PC': self.list.append(getConfigListEntry(_("Resolution"), config.av.videorate[config.av.videomode[config.av.videoport.value].value], _("This option configures the screen resolution in PC output mode."))) elif config.av.videoport.value != 'Scart': self.list.append(getConfigListEntry(_("Refresh rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value], _("Configure the refresh rate of the screen. Multi means refresh rate depends on the source 24/50/60Hz"))) if config.av.autores.value in ('all', 'hd') or config.av.videorate[config.av.videomode[config.av.videoport.value].value].value == 'multi': self.list.append(getConfigListEntry(_("Delay time"), config.av.autores_delay,_("Set the time before checking video source for resolution/refresh rate infomation."))) port = config.av.videoport.value if port not in config.av.videomode: mode = None else: mode = config.av.videomode[port].value # some modes (720p, 1080i) are always widescreen. Don't let the user select something here, "auto" is not what he wants. force_wide = self.hw.isWidescreenMode(port, mode) # if not force_wide: # self.list.append(getConfigListEntry(_("Aspect ratio"), config.av.aspect, _("Configure the aspect ratio of the screen."))) if force_wide or config.av.aspect.value in ("16:9", "16:10"): self.list.extend(( getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43, _("When the content has an aspect ratio of 4:3, choose whether to scale/stretch the picture.")), getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture.")) )) elif config.av.aspect.value == "4:3": self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture."))) if config.av.videoport.value == "Scart": self.list.append(getConfigListEntry(_("Color format"), config.av.colorformat, _("Configure which color format should be used on the SCART output."))) if level >= 1: self.list.append(getConfigListEntry(_("WSS on 4:3"), config.av.wss, _("When enabled, content with an aspect ratio of 4:3 will be stretched to fit the screen."))) if SystemInfo["ScartSwitch"]: self.list.append(getConfigListEntry(_("Auto scart switching"), config.av.vcrswitch, _("When enabled, your receiver will detect activity on the VCR SCART input."))) if SystemInfo["havecolorspace"]: self.list.append(getConfigListEntry(_("HDMI Colorspace"), config.av.hdmicolorspace,_("This option allows you to change the Colorspace from Auto to RGB"))) if SystemInfo["havecolorimetry"]: self.list.append(getConfigListEntry(_("HDMI Colorimetry"), config.av.hdmicolorimetry,_("This option allows you to change the Colorimetry for HDR"))) if SystemInfo["havehdmicolordepth"]: self.list.append(getConfigListEntry(_("HDMI Colordepth"), config.av.hdmicolordepth,_("This option allows you to change the Colordepth for UHD"))) if level >= 1: if SystemInfo["CanDownmixAC3"]: self.list.append(getConfigListEntry(_("AC3 downmix"), config.av.downmix_ac3, _("Choose whether multi channel ac3 sound tracks should be downmixed to stereo."))) if SystemInfo["CanDownmixDTS"]: self.list.append(getConfigListEntry(_("DTS downmix"), config.av.downmix_dts, _("Choose whether multi channel dts sound tracks should be downmixed to stereo."))) if SystemInfo["CanDownmixAAC"]: self.list.append(getConfigListEntry(_("AAC downmix"), config.av.downmix_aac, _("Choose whether multi channel aac sound tracks should be downmixed to stereo."))) if SystemInfo["CanAACTranscode"]: self.list.append(getConfigListEntry(_("AAC transcoding"), config.av.transcodeaac, _("Choose whether AAC sound tracks should be transcoded."))) if SystemInfo["CanPcmMultichannel"]: self.list.append(getConfigListEntry(_("PCM Multichannel"), config.av.pcm_multichannel, _("Choose whether multi channel sound tracks should be output as PCM."))) self.list.extend(( getConfigListEntry(_("General AC3 delay"), config.av.generalAC3delay, _("This option configures the general audio delay of Dolby Digital sound tracks.")), getConfigListEntry(_("General PCM delay"), config.av.generalPCMdelay, _("This option configures the general audio delay of stereo sound tracks.")) )) if SystemInfo["Can3DSurround"]: self.list.append(getConfigListEntry(_("3D Surround"), config.av.surround_3d,_("This option allows you to enable 3D Surround Sound for an output."))) if SystemInfo["Can3DSpeaker"] and config.av.surround_3d.value != "none": self.list.append(getConfigListEntry(_("3D Surround Speaker Position"), config.av.surround_3d_speaker,_("This option allows you to change the virtual loudspeaker position."))) if SystemInfo["CanAutoVolume"]: self.list.append(getConfigListEntry(_("Auto Volume Level"), config.av.autovolume,_("This option configures output for Auto Volume Level."))) if SystemInfo["Canedidchecking"]: self.list.append(getConfigListEntry(_("Bypass HDMI EDID Check"), config.av.bypass_edid_checking,_("This option allows you to bypass HDMI EDID check"))) if SystemInfo["haveboxmode"]: self.list.append(getConfigListEntry(_("Video Chip Mode*"), config.av.boxmode,_("Choose between High Dynamic Range (HDR) or Picture in Picture (PIP). Both are not possible at the same time. A FULL REBOOT is required for it to take effect"))) # if not isinstance(config.av.scaler_sharpness, ConfigNothing): # self.list.append(getConfigListEntry(_("Scaler sharpness"), config.av.scaler_sharpness, _("This option configures the picture sharpness."))) self["config"].list = self.list self["config"].l.setList(self.list) if config.usage.sort_settings.value: self["config"].list.sort()
def VideoChangeDetect(self): global resolutionlabel config_port = config.av.videoport.value config_mode = str(config.av.videomode[config_port].value).replace('\n','') config_res = str(config.av.videomode[config_port].value[:-1]).replace('\n','') config_pol = str(config.av.videomode[config_port].value[-1:]).replace('\n','') config_rate = str(config.av.videorate[config_mode].value).replace('Hz','').replace('\n','') f = open("/proc/stb/video/videomode") current_mode = f.read()[:-1].replace('\n','') f.close() if current_mode.upper() in ('PAL', 'NTSC'): current_mode = current_mode.upper() current_pol = '' if 'i' in current_mode: current_pol = 'i' elif 'p' in current_mode: current_pol = 'p' current_res = current_pol and current_mode.split(current_pol)[0].replace('\n','') or "" current_rate = current_pol and current_mode.split(current_pol)[0].replace('\n','') and current_mode.split(current_pol)[1].replace('\n','') or "" video_height = None video_width = None video_pol = None video_rate = None if path.exists("/proc/stb/vmpeg/0/yres"): f = open("/proc/stb/vmpeg/0/yres", "r") try: video_height = int(f.read(),16) except: pass f.close() if path.exists("/proc/stb/vmpeg/0/xres"): f = open("/proc/stb/vmpeg/0/xres", "r") try: video_width = int(f.read(),16) except: pass f.close() if path.exists("/proc/stb/vmpeg/0/progressive"): f = open("/proc/stb/vmpeg/0/progressive", "r") try: video_pol = "p" if int(f.read(),16) else "i" except: pass f.close() if path.exists("/proc/stb/vmpeg/0/framerate"): f = open("/proc/stb/vmpeg/0/framerate", "r") try: video_rate = int(f.read()) except: pass f.close() if not video_height or not video_width or not video_pol or not video_rate: service = self.session.nav.getCurrentService() if service is not None: info = service.info() else: info = None if info: video_height = int(info.getInfo(iServiceInformation.sVideoHeight)) video_width = int(info.getInfo(iServiceInformation.sVideoWidth)) video_pol = ("i", "p")[info.getInfo(iServiceInformation.sProgressive)] video_rate = int(info.getInfo(iServiceInformation.sFrameRate)) if video_height and video_width and video_pol and video_rate: resolutionlabel["content"].setText(_("Video content: %ix%i%s %iHz") % (video_width, video_height, video_pol, (video_rate + 500) / 1000)) if (700 < video_width <= 720) and video_height <= 480 and video_rate in (23976, 24000, 29970, 59940): new_res = "480" elif (700 < video_width <= 720) and video_height <= 576 and video_rate in (25000, 50000): new_res = "576" elif (video_width == 1280) and video_height <= 720: new_res = "720" elif (video_width == 1920) and video_height <= 1080: new_res = "1080" elif (video_width == 3840) and video_height > 1080: new_res = "2160" else: new_res = config_res if video_rate != -1: if video_rate == 25000 and video_pol == 'i': new_rate = 50000 elif video_rate == 59940 or (video_rate == 29970 and video_pol == 'i') or (video_rate == 29970 and video_pol == 'p' and config.av.autores.value == 'disabled'): new_rate = 60000 elif video_rate == 23976: new_rate = 24000 elif video_rate == 29970: new_rate = 30000 else: new_rate = video_rate new_rate = str((new_rate + 500) / 1000) else: new_rate = config_rate if video_pol != -1: new_pol = str(video_pol) else: new_pol = config_pol write_mode = None new_mode = None if config_mode in ('PAL', 'NTSC'): write_mode = config_mode elif config.av.autores.value == 'all' or (config.av.autores.value == 'hd' and int(new_res) >= 720): if (config.av.autores_deinterlace.value and HardwareInfo().is_nextgen()) or (config.av.autores_deinterlace.value and not HardwareInfo().is_nextgen() and int(new_res) <= 720): new_pol = new_pol.replace('i','p') if new_res+new_pol+new_rate in iAVSwitch.readAvailableModes(): new_mode = new_res+new_pol+new_rate if new_mode == '480p24' or new_mode == '576p24': new_mode = config.av.autores_480p24.value if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25' or new_mode == '2160p50': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value elif new_res+new_pol in iAVSwitch.readAvailableModes(): new_mode = new_res+new_pol if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value else: new_mode = config_mode+new_rate write_mode = new_mode elif config.av.autores.value == 'hd' and int(new_res) <= 576: if (config.av.autores_deinterlace.value and HardwareInfo().is_nextgen()) or (config.av.autores_deinterlace.value and not HardwareInfo().is_nextgen() and not config.av.autores_sd.value == '1080i'): new_mode = config.av.autores_sd.value.replace('i','p')+new_rate else: if new_pol in 'p': new_mode = config.av.autores_sd.value.replace('i','p')+new_rate else: new_mode = config.av.autores_sd.value+new_rate if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30': new_mode = config.av.autores_2160p30.value write_mode = new_mode else: if path.exists('/proc/stb/video/videomode_%shz' % new_rate) and config_rate == 'multi': try: f = open("/proc/stb/video/videomode_%shz" % new_rate, "r") multi_videomode = f.read().replace('\n','') f.close() if multi_videomode and (current_mode != multi_videomode): write_mode = multi_videomode else: write_mode = current_mode except IOError: write_mode = current_mode if write_mode and current_mode != write_mode: resolutionlabel["restxt"].setText(_("Video mode: %s") % write_mode) if config.av.autores.value != "disabled" and config.av.autores_label_timeout.value != '0': resolutionlabel.show() print "[VideoMode] setMode - port: %s, mode: %s" % (config_port, write_mode) f = open("/proc/stb/video/videomode", "w") f.write(write_mode) f.close() iAVSwitch.setAspect(config.av.aspect) iAVSwitch.setWss(config.av.wss) iAVSwitch.setPolicy43(config.av.policy_43) iAVSwitch.setPolicy169(config.av.policy_169) self.delay = False self.detecttimer.stop()
from boxbranding import getImageDistro, getBoxType try: from Components.AVSwitch import iAVSwitch as video_hw except: from Plugins.SystemPlugins.Videomode.VideoHardware import video_hw # depends on Videomode Plugin # modes_available used to be a member variable, but that was removed and # the value can now only be accessed using an accessor function. # Need to cater for either... # if hasattr(video_hw, "modes_available"): modes_available = video_hw.modes_available else: modes_available = video_hw.readAvailableModes() usable = False preferedmodes = None default = None port = None videoresolution_dictionary = {} resolutionlabel = None manualResolution = None resolutions = ( ('sd_i_50', _("SD 25/50HZ Interlace Mode")), ('sd_i_60', _("SD 30/60HZ Interlace Mode")), ('sd_p_24', _("SD 24HZ Progressive mode")), ('sd_p_50', _("SD 25/50HZ Progressive Mode")), ('sd_p_60', _("SD 30/60HZ Progressive Mode")),
def VideoChangeDetect(self): # info: autoresolution preview or save settings call this function with session = None / ~338, ~374 global resolutionlabel config_port, config_mode, config_res, config_pol, config_rate = getConfig_videomode(config.av.videomode, config.av.videorate) config_mode = config_mode.replace('p30', 'p') f = open("/proc/stb/video/videomode") current_mode = f.read()[:-1].replace('\n', '') f.close() if current_mode.upper() in ('PAL', 'NTSC'): current_mode = current_mode.upper() current_pol = '' if 'i' in current_mode: current_pol = 'i' elif 'p' in current_mode: current_pol = 'p' current_res = current_pol and current_mode.split(current_pol)[0].replace('\n', '') or "" current_rate = current_pol and current_mode.split(current_pol)[0].replace('\n', '') and current_mode.split(current_pol)[1].replace('\n', '') or "" write_mode = None new_mode = None video_height = None video_width = None video_pol = None video_rate = None if path.exists("/proc/stb/vmpeg/0/yres"): try: f = open("/proc/stb/vmpeg/0/yres", "r") video_height = int(f.read(), 16) f.close() except: video_height = 0 if path.exists("/proc/stb/vmpeg/0/xres"): try: f = open("/proc/stb/vmpeg/0/xres", "r") video_width = int(f.read(), 16) f.close() except: video_width = 0 if path.exists("/proc/stb/vmpeg/0/progressive"): try: f = open("/proc/stb/vmpeg/0/progressive", "r") video_pol = "p" if int(f.read(), 16) else "i" f.close() except: video_pol = "i" if path.exists("/proc/stb/vmpeg/0/framerate"): f = open("/proc/stb/vmpeg/0/framerate", "r") try: video_rate = int(f.read()) except: video_rate = 50 f.close() if not video_height or not video_width or not video_pol or not video_rate: service = self.session and self.session.nav.getCurrentService() if service is not None: info = service.info() else: info = None if info: video_height = int(info.getInfo(iServiceInformation.sVideoHeight)) video_width = int(info.getInfo(iServiceInformation.sVideoWidth)) video_pol = ("i", "p")[info.getInfo(iServiceInformation.sProgressive)] video_rate = int(info.getInfo(iServiceInformation.sFrameRate)) print("[VideoMode] detect video height: %s, width: %s, pol: %s, rate: %s (current video mode: %s)" % (video_height, video_width, video_pol, video_rate, current_mode)) if video_height and video_width and video_pol and video_rate: label_rate = (video_rate + 500) / 1000 if video_pol == 'i': label_rate *= 2 resolutionlabel["content"].setText(_("Video content: %ix%i%s %iHz") % (video_width, video_height, video_pol, label_rate)) if video_height != -1: if video_height > 720 or video_width > 1280: new_res = "1080" elif (576 < video_height <= 720) or video_width > 1024: new_res = "720" elif (480 < video_height <= 576) or video_width > 720 or video_rate in (25000, 23976, 24000): new_res = "576" else: new_res = "480" else: new_res = config_res if video_rate != -1: if video_rate == 25000 and video_pol == 'i': new_rate = 50000 elif video_rate == 59940 or (video_rate == 29970 and video_pol == 'i'): new_rate = 60000 elif video_rate == 23976: new_rate = 24000 elif video_rate == 29970: new_rate = 30000 else: new_rate = video_rate new_rate = str((new_rate + 500) / 1000) else: new_rate = config_rate if video_pol != -1: new_pol = str(video_pol) else: new_pol = config_pol autorestyp = "" if config_mode in ('PAL', 'NTSC'): autorestyp = 'PAL or NTSC' write_mode = config_mode elif config.av.autores.value == 'simple': autorestyp = 'simple' new_rate = (video_rate + 500) / 1000 if video_height <= 576 and int(config_res) >= 576: #sd if config.av.autores_rate_sd[config.av.autores_mode_sd[config.av.videoport.value].value].value in ("auto", "multi"): if video_pol == 'i': new_rate *= 2 else: new_rate = config.av.autores_rate_sd[config.av.autores_mode_sd[config.av.videoport.value].value].value.replace('Hz', '') new_mode = config.av.autores_mode_sd[config_port].value.replace('p30', 'p') elif video_height <= 720 and int(config_res) >= 720: #hd if config.av.autores_rate_hd[config.av.autores_mode_hd[config.av.videoport.value].value].value in ("auto", "multi"): if video_pol == 'i': new_rate *= 2 else: new_rate = config.av.autores_rate_hd[config.av.autores_mode_hd[config.av.videoport.value].value].value.replace('Hz', '') new_mode = config.av.autores_mode_hd[config_port].value.replace('p30', 'p') elif video_height <= 1080 and int(config_res) >= 1080: #fhd if config.av.autores_rate_fhd[config.av.autores_mode_fhd[config.av.videoport.value].value].value in ("auto", "multi"): if video_pol == 'i': new_rate *= 2 else: new_rate = config.av.autores_rate_fhd[config.av.autores_mode_fhd[config.av.videoport.value].value].value.replace('Hz', '') new_mode = config.av.autores_mode_fhd[config_port].value.replace('p30', 'p') if new_mode == '1080p' and not config.av.autores_1080i_deinterlace.value and video_height == 1080 and video_pol == 'i': new_mode = '1080i' elif video_height <= 2160 and int(config_res) >= 2160: #uhd if config.av.autores_rate_uhd[config.av.autores_mode_uhd[config.av.videoport.value].value].value in ("auto", "multi"): if video_pol == 'i': new_rate *= 2 else: new_rate = config.av.autores_rate_uhd[config.av.autores_mode_uhd[config.av.videoport.value].value].value.replace('Hz', '') new_mode = config.av.autores_mode_uhd[config_port].value.replace('p30', 'p') else: if config_rate not in ("auto", "multi"): new_rate = config_rate new_mode = config_mode new_rate = str(new_rate) if new_mode[-1:] == 'p': new_rate = setProgressiveRate((video_rate + 500) / 1000 * (int(video_pol == 'i') + 1), new_rate, new_mode[:-1], config_res, config_rate) if new_mode + new_rate in iAVSwitch.readAvailableModes(): write_mode = new_mode + new_rate elif new_mode in iAVSwitch.readAvailableModes(): write_mode = new_mode else: if config_rate not in ("auto", "multi") and int(new_rate) > int(config_rate): new_rate = config_rate if config_mode + new_rate in iAVSwitch.readAvailableModes(): write_mode = config_mode + new_rate else: write_mode = config_mode elif config.av.autores.value == 'native': autorestyp = 'native' new_rate = (video_rate + 500) / 1000 new_pol = video_pol new_res = str(video_height) if video_pol == 'i': new_rate *= 2 min_port, min_mode, min_res, min_pol, min_rate = getConfig_videomode(config.av.autores_mode_sd, config.av.autores_rate_sd) if video_height <= int(min_res): if new_pol == 'i' and min_pol == 'p': new_pol = min_pol if min_rate not in ("auto", "multi") and new_rate < int(min_rate): new_rate = min_rate new_res = min_res if video_height >= int(config_res) or int(new_res) >= int(config_res): new_res = config_res if video_pol == 'p' and config_pol == 'i': new_pol = config_pol if config_rate not in ("auto", "multi") and int(config_rate) < new_rate: new_rate = config_rate new_rate = str(new_rate) if new_pol == 'p': new_rate = setProgressiveRate((video_rate + 500) / 1000 * (int(video_pol == 'i') + 1), new_rate, new_res, config_res, config_rate) if new_res + new_pol + new_rate in iAVSwitch.readAvailableModes(): write_mode = new_res + new_pol + new_rate elif new_res + new_pol in iAVSwitch.readAvailableModes(): write_mode = new_res + new_pol elif new_res + min_pol + new_rate in iAVSwitch.readAvailableModes(): write_mode = new_res + min_pol + new_rate elif new_res + min_pol in iAVSwitch.readAvailableModes(): write_mode = new_res + min_pol else: if config.av.autores_unknownres.value == 'next': if video_height <= 576 and int(config_res) >= 576: new_res = '576' elif video_height <= 720 and int(config_res) >= 720: new_res = '720' elif video_height <= 1080 and int(config_res) >= 1080: new_res = '1080' elif video_height <= 2160 and int(config_res) >= 2160: new_res = '2160' elif config.av.autores_unknownres.value == 'highest': new_res = config_res if new_pol == 'p': new_rate = setProgressiveRate((video_rate + 500) / 1000 * (int(video_pol == 'i') + 1), new_rate, new_res, config_res, config_rate) if new_res + new_pol + new_rate in iAVSwitch.readAvailableModes(): write_mode = new_res + new_pol + new_rate elif new_res + new_pol in iAVSwitch.readAvailableModes(): write_mode = new_res + new_pol elif new_res + min_pol + new_rate in iAVSwitch.readAvailableModes(): write_mode = new_res + min_pol + new_rate elif new_res + min_pol in iAVSwitch.readAvailableModes(): write_mode = new_res + min_pol else: if config_rate not in ("auto", "multi") and int(new_rate) > int(config_rate): new_rate = config_rate if config_mode + new_rate in iAVSwitch.readAvailableModes(): write_mode = config_mode + new_rate else: write_mode = config_mode elif config.av.autores.value == 'all' or (config.av.autores.value == 'hd' and int(new_res) >= 720): autorestyp = 'all or hd' if config.av.autores_deinterlace.value: new_pol = new_pol.replace('i', 'p') if new_res + new_pol + new_rate in iAVSwitch.readAvailableModes(): new_mode = new_res + new_pol + new_rate if new_mode == '480p24' or new_mode == '576p24': new_mode = config.av.autores_480p24.value if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25' or new_mode == '2160p50': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value elif new_res + new_pol in iAVSwitch.readAvailableModes(): new_mode = new_res + new_pol if new_mode == '2160p30' or new_mode == '2160p60' or new_mode == '2160p': new_mode = config.av.autores_2160p30.value else: new_mode = config_mode + new_rate write_mode = new_mode elif config.av.autores.value == 'hd' and int(new_res) <= 576: autorestyp = 'hd' if new_pol == "p": new_mode = config.av.autores_sd.value.replace('i', 'p') + new_rate else: new_mode = config.av.autores_sd.value + new_rate if config.av.autores_deinterlace.value: test_new_mode = config.av.autores_sd.value.replace('i', 'p') + new_rate if test_new_mode in iAVSwitch.readAvailableModes(): new_mode = test_new_mode if new_mode == '720p24': new_mode = config.av.autores_720p24.value if new_mode == '1080p24': new_mode = config.av.autores_1080p24.value if new_mode == '1080p25': new_mode = config.av.autores_1080p25.value if new_mode == '1080p30': new_mode = config.av.autores_1080p30.value if new_mode == '2160p24': new_mode = config.av.autores_2160p24.value if new_mode == '2160p25': new_mode = config.av.autores_2160p25.value if new_mode == '2160p30': new_mode = config.av.autores_2160p30.value write_mode = new_mode else: autorestyp = 'no match' if path.exists('/proc/stb/video/videomode_%shz' % new_rate) and config_rate in ("auto", "multi"): f = open("/proc/stb/video/videomode_%shz" % new_rate, "r") multi_videomode = f.read().replace('\n', '') f.close() if multi_videomode and (current_mode != multi_videomode): write_mode = multi_videomode else: write_mode = config_mode + new_rate # workaround for bug, see https://www.opena.tv/forum/showthread.php?1642-Autoresolution-Plugin&p=38836&viewfull=1#post38836 # always use a fixed resolution and frame rate (e.g. 1080p50 if supported) for TV or .ts files # always use a fixed resolution and correct rate (e.g. 1080p24/p50/p60 for all other videos if config.av.smart1080p.value != 'false' and config.av.autores.value in ('all', 'hd'): autorestyp = 'smart1080p mode' ref = self.session and self.session.nav.getCurrentlyPlayingServiceReference() if ref is not None: try: mypath = ref.getPath() except: mypath = '' else: mypath = '' # no frame rate information available, check if filename (or directory name) contains a hint # (allow user to force a frame rate this way): if (mypath.find('p24.') >= 0) or (mypath.find('24p.') >= 0): new_rate = '24' elif (mypath.find('p25.') >= 0) or (mypath.find('25p.') >= 0): new_rate = '25' elif (mypath.find('p30.') >= 0) or (mypath.find('30p.') >= 0): new_rate = '30' elif (mypath.find('p50.') >= 0) or (mypath.find('50p.') >= 0): new_rate = '50' elif (mypath.find('p60.') >= 0) or (mypath.find('60p.') >= 0): new_rate = '60' elif new_rate in ("auto", "multi"): new_rate = '' # omit frame rate specifier, e.g. '1080p' instead of '1080p50' if there is no clue if mypath != '': if mypath.endswith('.ts'): print("DEBUG VIDEOMODE/ playing .ts file") new_rate = '50' # for .ts files else: print("DEBUG VIDEOMODE/ playing other (non .ts) file") # new_rate from above for all other videos else: print("DEBUG VIDEOMODE/ no path or no service reference, presumably live TV") new_rate = '50' # for TV / or no service reference, then stay at 1080p50 new_rate = new_rate.replace('25', '50') new_rate = new_rate.replace('30', '60') if (config.av.smart1080p.value == '1080p50') or (config.av.smart1080p.value == 'true'): # for compatibility with old ConfigEnableDisable write_mode = '1080p' + new_rate elif config.av.smart1080p.value == '2160p50': write_mode = '2160p' + new_rate elif config.av.smart1080p.value == '1080i50': if new_rate == '24': write_mode = '1080p24' # instead of 1080i24 else: write_mode = '1080i' + new_rate elif config.av.smart1080p.value == '720p50': write_mode = '720p' + new_rate #print "[VideoMode] smart1080p mode, selecting ",write_mode if write_mode and current_mode != write_mode and self.bufferfull or self.firstrun: # first we read now the real available values for every stb, # before we try to write the new mode changeResolution = False try: if path.exists("/proc/stb/video/videomode_choices"): vf = open("/proc/stb/video/videomode_choices") values = vf.readline().replace("\n", "").split(" ", -1) for x in values: if x == write_mode: try: f = open("/proc/stb/video/videomode", "w") f.write(write_mode) f.close() changeResolution = True except Exception as e: print("[VideoMode] write_mode exception:" + str(e)) if not changeResolution: print("[VideoMode] setMode - port: %s, mode: %s is not available" % (config_port, write_mode)) resolutionlabel["restxt"].setText(_("Video mode: %s not available") % write_mode) # we try to go for not available 1080p24/1080p30/1080p60 to change to 1080p from 60hz_choices if available # TODO: can we make it easier, or more important --> smaller ? # should we outsourced that way, like two new "def ..." # or some other stuff, not like this? if (write_mode == "1080p24") or (write_mode == "1080p30") or (write_mode == "1080p60"): for x in values: if x == "1080p": try: f = open("/proc/stb/video/videomode", "w") f.write(x) f.close() changeResolution = True except Exception as e: print("[VideoMode] write_mode exception:" + str(e)) if not changeResolution: print("[VideoMode] setMode - port: %s, mode: 1080p is also not available" % config_port) resolutionlabel["restxt"].setText(_("Video mode: 1080p also not available")) else: print("[VideoMode] setMode - port: %s, mode: 1080p" % config_port) resolutionlabel["restxt"].setText(_("Video mode: 1080p")) if (write_mode == "2160p24") or (write_mode == "2160p30") or (write_mode == "2160p60"): for x in values: if x == "2160p": try: f = open("/proc/stb/video/videomode", "w") f.write(x) f.close() changeResolution = True except Exception as e: print("[VideoMode] write_mode exception:" + str(e)) if not changeResolution: print("[VideoMode] setMode - port: %s, mode: 2160p is also not available" % config_port) resolutionlabel["restxt"].setText(_("Video mode: 2160p also not available")) else: print("[VideoMode] setMode - port: %s, mode: 2160p" % config_port) resolutionlabel["restxt"].setText(_("Video mode: 2160p")) else: resolutionlabel["restxt"].setText(_("Video mode: %s") % write_mode) print("[VideoMode] setMode - port: %s, mode: %s (autoresTyp: '%s')" % (config_port, write_mode, autorestyp)) if config.av.autores_label_timeout.value != '0': resolutionlabel.show() vf.close() except Exception as e: print("[VideoMode] read videomode_choices exception:" + str(e)) elif write_mode and current_mode != write_mode: # the resolution remained stuck at a wrong setting after streaming when self.bufferfull was False (should be fixed now after adding BufferInfoStop) print("[VideoMode] not changing from", current_mode, "to", write_mode, "as self.bufferfull is", self.bufferfull) if write_mode and write_mode != current_mode or self.firstrun: iAVSwitch.setAspect(config.av.aspect) iAVSwitch.setWss(config.av.wss) iAVSwitch.setPolicy43(config.av.policy_43) if hasattr(config.av, 'policy_169'): iAVSwitch.setPolicy169(config.av.policy_169) self.firstrun = False self.delay = False self.detecttimer.stop()
def createSetup(self): level = config.usage.setup_level.index self.list = [ getConfigListEntry(_("Video output"), config.av.videoport, _("Configures which video output connector will be used.")) ] if config.av.videoport.value in ('HDMI', 'YPbPr', 'Scart-YPbPr') and not getAutoresPlugin_enabled(): #path.exists(resolveFilename(SCOPE_PLUGINS)+'SystemPlugins/AutoResolution'): self.list.append(getConfigListEntry(_("Automatic resolution"), config.av.autores, _("If enabled the output resolution of the box will try to match the resolution of the video contents resolution"))) if config.av.autores.value in ('all', 'hd'): self.list.append(getConfigListEntry(_("Delay time"), config.av.autores_delay, _("Set the time before checking video source for resolution information."))) self.list.append(getConfigListEntry(_("Automatic resolution label"), config.av.autores_label_timeout, _("Allows you to adjust the amount of time the resolution information display on screen."))) self.list.append(getConfigListEntry(_("Force de-interlace"), config.av.autores_deinterlace, _("If enabled the video will always be de-interlaced."))) self.list.append(getConfigListEntry(_("Always use smart1080p mode"), config.av.smart1080p, _("This option allows you to always use e.g. 1080p50 for TV/.ts, and 1080p24/p50/p60 for videos"))) if config.av.autores.value in 'hd': self.list.append(getConfigListEntry(_("Show SD as"), config.av.autores_sd, _("This option allows you to choose how to display standard definition video on your TV."))) self.list.append(getConfigListEntry(_("Show 480/576p 24fps as"), config.av.autores_480p24, _("This option allows you to choose how to display SD progressive 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 720p 24fps as"), config.av.autores_720p24, _("This option allows you to choose how to display 720p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 24fps as"), config.av.autores_1080p24, _("This option allows you to choose how to display 1080p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 25fps as"), config.av.autores_1080p25, _("This option allows you to choose how to display 1080p 25Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 1080p 30fps as"), config.av.autores_1080p30, _("This option allows you to choose how to display 1080p 30Hz on your TV. (as not all TV's support these resolutions)"))) if '2160p24' in iAVSwitch.readAvailableModes(): self.list.append(getConfigListEntry(_("Show 2160p 24fps as"), config.av.autores_2160p24, _("This option allows you to choose how to display 2160p 24Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 2160p 25fps as"), config.av.autores_2160p25, _("This option allows you to choose how to display 2160p 25Hz on your TV. (as not all TV's support these resolutions)"))) self.list.append(getConfigListEntry(_("Show 2160p 30fps as"), config.av.autores_2160p30, _("This option allows you to choose how to display 2160p 30Hz on your TV. (as not all TV's support these resolutions)"))) elif config.av.autores.value == 'simple': self.list.append(getConfigListEntry(_("Delay time"), config.av.autores_delay, _("Set the time before checking video source for resolution information."))) self.list.append(getConfigListEntry(_("Automatic resolution label"), config.av.autores_label_timeout, _("Allows you to adjust the amount of time the resolution information display on screen."))) self.prev_sd = self.prev_hd = self.prev_fhd = self.prev_uhd = "" service = self.session.nav.getCurrentService() info = service and service.info() if info: video_height = int(info.getInfo(iServiceInformation.sVideoHeight)) if video_height <= 576: self.prev_sd = "* " elif video_height <= 720: self.prev_hd = "* " elif video_height <= 1080: self.prev_fhd = "* " elif video_height <= 2160: self.prev_uhd = "* " else: config.av.autores_preview.value = False self.list.append(getConfigListEntry(_("Enable preview"), config.av.autores_preview, _("Show preview of current mode (*)."), "check")) else: config.av.autores_preview.value = False self.getVerify_videomode(config.av.autores_mode_sd, config.av.autores_rate_sd) self.list.append(getConfigListEntry(pgettext(_("Video output mode for SD"), _("%sMode for SD (up to 576p)") % self.prev_sd), config.av.autores_mode_sd[config.av.videoport.value], _("This option configures the video output mode (or resolution)."), "check_sd")) self.list.append(getConfigListEntry(_("%sRefresh rate for SD") % self.prev_sd, config.av.autores_rate_sd[config.av.autores_mode_sd[config.av.videoport.value].value], _("Configure the refresh rate of the screen."), "check_sd")) modelist = iAVSwitch.getModeList(config.av.videoport.value) if '720p' in iAVSwitch.readAvailableModes(): self.getVerify_videomode(config.av.autores_mode_hd, config.av.autores_rate_hd) self.list.append(getConfigListEntry(pgettext(_("Video output mode for HD"), _("%sMode for HD (up to 720p)") % self.prev_hd), config.av.autores_mode_hd[config.av.videoport.value], _("This option configures the video output mode (or resolution)."), "check_hd")) self.list.append(getConfigListEntry(_("%sRefresh rate for HD") % self.prev_hd, config.av.autores_rate_hd[config.av.autores_mode_hd[config.av.videoport.value].value], _("Configure the refresh rate of the screen."), "check_hd")) if '1080i' in iAVSwitch.readAvailableModes() or '1080p' in iAVSwitch.readAvailableModes(): self.getVerify_videomode(config.av.autores_mode_fhd, config.av.autores_rate_fhd) self.list.append(getConfigListEntry(pgettext(_("Video output mode for FHD"), _("%sMode for FHD (up to 1080p)") % self.prev_fhd), config.av.autores_mode_fhd[config.av.videoport.value], _("This option configures the video output mode (or resolution)."), "check_fhd")) self.list.append(getConfigListEntry(_("%sRefresh rate for FHD") % self.prev_fhd, config.av.autores_rate_fhd[config.av.autores_mode_fhd[config.av.videoport.value].value], _("Configure the refresh rate of the screen."), "check_fhd")) if config.av.autores_mode_fhd[config.av.videoport.value].value == '1080p' and ('1080p' in iAVSwitch.readAvailableModes() or '1080p50' in iAVSwitch.readAvailableModes()): self.list.append(getConfigListEntry(_("%sShow 1080i as 1080p") % self.prev_fhd, config.av.autores_1080i_deinterlace, _("Use Deinterlacing for 1080i Videosignal?"), "check_fhd")) elif not '1080p' in iAVSwitch.readAvailableModes() and not '1080p50' in iAVSwitch.readAvailableModes(): config.av.autores_1080i_deinterlace.setValue(False) if '2160p' in iAVSwitch.readAvailableModes() or '2160p30' in iAVSwitch.readAvailableModes(): self.getVerify_videomode(config.av.autores_mode_uhd, config.av.autores_rate_uhd) self.list.append(getConfigListEntry(pgettext(_("Video output mode for UHD"), _("%sMode for UHD (up to 2160p)") % self.prev_uhd), config.av.autores_mode_uhd[config.av.videoport.value], _("This option configures the video output mode (or resolution)."), "check_uhd")) self.list.append(getConfigListEntry(_("%sRefresh rate for UHD") % self.prev_uhd, config.av.autores_rate_uhd[config.av.autores_mode_uhd[config.av.videoport.value].value], _("Configure the refresh rate of the screen."), "check_uhd")) self.list.append(getConfigListEntry(_("Show 24p up to 720p / higher than 720p as"), config.av.autores_24p, _("Show 24p up to resolution 720p or higher than 720p as a different Framerate."))) self.list.append(getConfigListEntry(_("Show 25p up to 720p / higher than 720p as"), config.av.autores_25p, _("Show 25p up to resolution 720p or higher than 720p as a different Framerate."))) self.list.append(getConfigListEntry(_("Show 30p up to 720p / higher than 720p as"), config.av.autores_30p, _("Show 30p up to resolution 720p or higher than 720p as a different Framerate."))) elif config.av.autores.value == 'native': self.list.append(getConfigListEntry(_("Delay time"), config.av.autores_delay, _("Set the time before checking video source for resolution information."))) self.list.append(getConfigListEntry(_("Automatic resolution label"), config.av.autores_label_timeout, _("Allows you to adjust the amount of time the resolution information display on screen."))) self.getVerify_videomode(config.av.autores_mode_sd, config.av.autores_rate_sd) self.list.append(getConfigListEntry(pgettext(_("Lowest Video output mode"), _("Lowest Mode")), config.av.autores_mode_sd[config.av.videoport.value], _("This option configures the video output mode (or resolution)."))) self.list.append(getConfigListEntry(_("Refresh rate for 'Lowest Mode'"), config.av.autores_rate_sd[config.av.autores_mode_sd[config.av.videoport.value].value], _("Configure the refresh rate of the screen."))) self.list.append(getConfigListEntry(_("Show 24p up to 720p / higher than 720p as"), config.av.autores_24p, _("Show 24p up to resolution 720p or higher than 720p as a different Framerate."))) self.list.append(getConfigListEntry(_("Show 25p up to 720p / higher than 720p as"), config.av.autores_25p, _("Show 25p up to resolution 720p or higher than 720p as a different Framerate."))) self.list.append(getConfigListEntry(_("Show 30p up to 720p / higher than 720p as"), config.av.autores_30p, _("Show 30p up to resolution 720p or higher than 720p as a different Framerate."))) self.list.append(getConfigListEntry(_("Show unknown video format as"), config.av.autores_unknownres, _("Show unknown Videoresolution as next higher or as highest screen resolution."))) # if we have modes for this port: if (config.av.videoport.value in config.av.videomode and config.av.autores.value == 'disabled') or config.av.videoport.value == 'Scart': # add mode- and rate-selection: self.list.append(getConfigListEntry(pgettext(_("Video output mode"), _("Mode")), config.av.videomode[config.av.videoport.value], _("This option configures the video output mode (or resolution)."))) if config.av.videomode[config.av.videoport.value].value == 'PC': self.list.append(getConfigListEntry(_("Resolution"), config.av.videorate[config.av.videomode[config.av.videoport.value].value], _("This option configures the screen resolution in PC output mode."))) elif config.av.videoport.value != 'Scart': self.list.append(getConfigListEntry(_("Refresh rate"), config.av.videorate[config.av.videomode[config.av.videoport.value].value], _("Configure the refresh rate of the screen."))) port = config.av.videoport.value if port not in config.av.videomode: mode = None else: mode = config.av.videomode[port].value # some modes (720p, 1080i) are always widescreen. Don't let the user select something here, "auto" is not what he wants. force_wide = self.hw.isWidescreenMode(port, mode) if not force_wide: self.list.append(getConfigListEntry(_("Aspect ratio"), config.av.aspect, _("Configure the aspect ratio of the screen."))) if hasattr(config.av, 'policy_169'): if force_wide or config.av.aspect.value in ("16:9", "16:10"): self.list.extend(( getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43, _("When the content has an aspect ratio of 4:3, choose whether to scale/stretch the picture.")), getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture.")) )) elif config.av.aspect.value == "4:3": self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture."))) else: if force_wide or config.av.aspect.value in ("16:9", "16:10"): self.list.append(getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43, _("When the content has an aspect ratio of 4:3, choose whether to scale/stretch the picture."))) elif config.av.aspect.value == "4:3": self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_43, _("When the content has an aspect ratio of 16:9, choose whether to scale/stretch the picture."))) if config.av.videoport.value == "HDMI": self.list.append(getConfigListEntry(_("Allow unsupported modes"), config.av.edid_override, _("This option allows you to use all HDMI Modes"))) if config.av.videoport.value == "Scart": self.list.append(getConfigListEntry(_("Color format"), config.av.colorformat, _("Configure which color format should be used on the SCART output."))) if level >= 1: self.list.append(getConfigListEntry(_("WSS on 4:3"), config.av.wss, _("When enabled, content with an aspect ratio of 4:3 will be stretched to fit the screen."))) if BoxInfo.getItem("ScartSwitch"): self.list.append(getConfigListEntry(_("Auto scart switching"), config.av.vcrswitch, _("When enabled, your receiver will detect activity on the VCR SCART input."))) if not isinstance(config.av.scaler_sharpness, ConfigNothing) and not isPluginInstalled("VideoEnhancement"): self.list.append(getConfigListEntry(_("Scaler sharpness"), config.av.scaler_sharpness, _("This option configures the picture sharpness."))) if BoxInfo.getItem("havecolorspace"): self.list.append(getConfigListEntry(_("HDMI Colorspace"), config.av.hdmicolorspace, _("This option allows you can config the Colorspace from Auto to RGB"))) if BoxInfo.getItem("havecolorimetry"): self.list.append(getConfigListEntry(_("HDMI Colorimetry"), config.av.hdmicolorimetry, _("This option allows you can config the Colorimetry for HDR"))) if BoxInfo.getItem("havehdmicolordepth"): self.list.append(getConfigListEntry(_("HDMI Colordepth"), config.av.hdmicolordepth, _("This option allows you can config the Colordepth for UHD"))) if BoxInfo.getItem("havehdmihdrtype"): self.list.append(getConfigListEntry(_("HDMI HDR Type"), config.av.hdmihdrtype, _("This option allows you can force the HDR Modes for UHD"))) if BoxInfo.getItem("Canedidchecking"): self.list.append(getConfigListEntry(_("Bypass HDMI EDID Check"), config.av.bypass_edid_checking, _("This option allows you to bypass HDMI EDID check"))) if BoxInfo.getItem("haveboxmode"): self.list.append(getConfigListEntry(_("Change Boxmode to control Hardware Chip Modes*"), config.av.boxmode, _("Switch Mode to enable HDR Modes or PiP Functions"))) if BoxInfo.getItem("HDRSupport"): self.list.append(getConfigListEntry(_("HLG Support"), config.av.hlg_support, _("This option allows you can force the HLG Modes for UHD"))) self.list.append(getConfigListEntry(_("HDR10 Support"), config.av.hdr10_support, _("This option allows you can force the HDR10 Modes for UHD"))) self.list.append(getConfigListEntry(_("Allow 12bit"), config.av.allow_12bit, _("This option allows you can enable or disable the 12 Bit Color Mode"))) self.list.append(getConfigListEntry(_("Allow 10bit"), config.av.allow_10bit, _("This option allows you can enable or disable the 10 Bit Color Mode"))) self["config"].list = self.list self["config"].l.setList(self.list) if config.usage.sort_settings.value: self["config"].list.sort()