(
self,
*,
quality: int,
every_nth_frame: int,
viewport: dict[str, int],
)
| 324 | self._expected_height = 0 |
| 325 | |
| 326 | async def start( |
| 327 | self, |
| 328 | *, |
| 329 | quality: int, |
| 330 | every_nth_frame: int, |
| 331 | viewport: dict[str, int], |
| 332 | ) -> None: |
| 333 | self.session.on("Page.screencastFrame", self._on_frame) |
| 334 | width = max(320, min(4096, int(viewport.get("width") or DEFAULT_VIEWPORT["width"]))) |
| 335 | height = max(200, min(4096, int(viewport.get("height") or DEFAULT_VIEWPORT["height"]))) |
| 336 | self._expected_width = width |
| 337 | self._expected_height = height |
| 338 | with contextlib.suppress(Exception): |
| 339 | await self.session.send("Page.enable") |
| 340 | await self._apply_cdp_viewport_with_remount({"width": width, "height": height}) |
| 341 | await self.session.send( |
| 342 | "Page.startScreencast", |
| 343 | { |
| 344 | "format": "jpeg", |
| 345 | "quality": max(20, min(95, int(quality))), |
| 346 | "maxWidth": SCREENCAST_MAX_WIDTH, |
| 347 | "maxHeight": SCREENCAST_MAX_HEIGHT, |
| 348 | "everyNthFrame": max(1, int(every_nth_frame)), |
| 349 | }, |
| 350 | ) |
| 351 | |
| 352 | async def _apply_cdp_viewport_with_remount(self, viewport: dict[str, int]) -> None: |
| 353 | await self._apply_cdp_viewport(viewport) |
no test coverage detected