Skip to content

Commit

Permalink
Merge pull request #56 from bigbluebutton/zoom-limit
Browse files Browse the repository at this point in the history
Limit the maximum zoom level
  • Loading branch information
antobinary authored Oct 31, 2024
2 parents cd5d224 + 0ccd676 commit c8cbb96
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bbb_presentation_video/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,26 @@ def parse_pan_zoom(

width_ratio = xml_subelement(element, name, "widthRatio")
height_ratio = xml_subelement(element, name, "heightRatio")

# Some BBB versions can produce invalid NaN ratios which can't be parsed as floats
if width_ratio == "NaN" or height_ratio == "NaN":
event["zoom"] = Size(1.0, 1.0)
else:
event["zoom"] = Size(float(width_ratio) / 100, float(height_ratio) / 100)

# Workaround a bug where BBB can return a width or height ratio of 0,
# which is nonsensical and causes divide-by-zero errors.
# It can also return values less than zero, I dunno what's up with that.
if event["zoom"].width <= 0 or event["zoom"].height <= 0:
event["zoom"] = Size(1.0, 1.0)

# The max zoom permitted in the BBB client is 400% (i.e. show 1/4 of the width of the slide)
# Apply a hard limit at 800% to prevent processing errors
if event["zoom"].width < 0.125:
event["zoom"] = Size(
0.125, event["zoom"].height * (0.125 / event["zoom"].height)
)

pod_id = xml_subelement_opt(element, "podId")
event["pod_id"] = pod_id if pod_id is not None else DEFAULT_PRESENTATION_POD

Expand Down

0 comments on commit c8cbb96

Please sign in to comment.