Fix ONVIF PTZ and profile encoding issues (#36006)
* allow lib to create AsyncTransport * fix transport close issue * fix zoom only cameras without PTZ presets * catch profiles without encoding configuration * also catch ServerDisconnectedError for ptzpull/36070/head
parent
22a12cea5c
commit
cf6cc6c07c
|
@ -219,7 +219,8 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
media_service = device.create_media_service()
|
||||
profiles = await media_service.GetProfiles()
|
||||
h264 = any(
|
||||
profile.VideoEncoderConfiguration.Encoding == "H264"
|
||||
profile.VideoEncoderConfiguration
|
||||
and profile.VideoEncoderConfiguration.Encoding == "H264"
|
||||
for profile in profiles
|
||||
)
|
||||
|
||||
|
|
|
@ -255,7 +255,10 @@ class ONVIFDevice:
|
|||
profiles = []
|
||||
for key, onvif_profile in enumerate(result):
|
||||
# Only add H264 profiles
|
||||
if onvif_profile.VideoEncoderConfiguration.Encoding != "H264":
|
||||
if (
|
||||
not onvif_profile.VideoEncoderConfiguration
|
||||
or onvif_profile.VideoEncoderConfiguration.Encoding != "H264"
|
||||
):
|
||||
continue
|
||||
|
||||
profile = Profile(
|
||||
|
@ -282,9 +285,13 @@ class ONVIFDevice:
|
|||
is not None,
|
||||
)
|
||||
|
||||
ptz_service = self.device.create_ptz_service()
|
||||
presets = await ptz_service.GetPresets(profile.token)
|
||||
profile.ptz.presets = [preset.token for preset in presets]
|
||||
try:
|
||||
ptz_service = self.device.create_ptz_service()
|
||||
presets = await ptz_service.GetPresets(profile.token)
|
||||
profile.ptz.presets = [preset.token for preset in presets]
|
||||
except (Fault, ServerDisconnectedError):
|
||||
# It's OK if Presets aren't supported
|
||||
profile.ptz.presets = []
|
||||
|
||||
profiles.append(profile)
|
||||
|
||||
|
|
Loading…
Reference in New Issue