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 ptz
pull/36070/head
Jason Hunter 2020-05-22 21:11:30 -04:00 committed by Franck Nijhof
parent 22a12cea5c
commit cf6cc6c07c
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 13 additions and 5 deletions

View File

@ -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
)

View File

@ -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)